Move on-event*.* to event-rule-matches*.*
[lttng-tools.git] / src / bin / lttng-sessiond / ust-app.c
index 3efda83c194149bedcf68a083db077897297e4dd..eb5c5a2ead4f2c1652da68782e86c03fd06783c6 100644 (file)
@@ -29,8 +29,8 @@
 #include <lttng/event-rule/event-rule-internal.h>
 #include <lttng/event-rule/tracepoint.h>
 #include <lttng/condition/condition.h>
-#include <lttng/condition/on-event-internal.h>
-#include <lttng/condition/on-event.h>
+#include <lttng/condition/event-rule-matches-internal.h>
+#include <lttng/condition/event-rule-matches.h>
 #include <lttng/trigger/trigger-internal.h>
 #include <common/sessiond-comm/sessiond-comm.h>
 
@@ -1271,6 +1271,8 @@ static struct ust_app_event_notifier_rule *alloc_ust_app_event_notifier_rule(
        assert(LTTNG_CONDITION_STATUS_OK == lttng_condition_on_event_get_rule(condition, &event_rule));
        assert(event_rule);
 
+       ua_event_notifier_rule->error_counter_index =
+                       lttng_condition_on_event_get_error_counter_index(condition);
        /* Acquire the event notifier's reference to the trigger. */
        lttng_trigger_get(trigger);
 
@@ -2954,7 +2956,7 @@ static int do_consumer_create_channel(struct ltt_ust_session *usess,
        health_code_update();
 
        /*
-        * Now get the channel from the consumer. This call wil populate the stream
+        * Now get the channel from the consumer. This call will populate the stream
         * list of that channel and set the ust objects.
         */
        if (usess->consumer->enabled) {
@@ -4065,13 +4067,29 @@ int ust_app_setup_event_notifier_group(struct ust_app *app)
 
        event_notifier_error_accounting_status = event_notifier_error_accounting_register_app(app);
        if (event_notifier_error_accounting_status != EVENT_NOTIFIER_ERROR_ACCOUNTING_STATUS_OK) {
+               if (event_notifier_error_accounting_status == EVENT_NOTIFIER_ERROR_ACCOUNTING_STATUS_APP_DEAD) {
+                       DBG3("Failed to setup event notifier error accounting (application is dead): app socket fd = %d",
+                                       app->sock);
+                       ret = 0;
+                       goto error_accounting;
+               }
+
                ERR("Failed to setup event notifier error accounting for app");
                ret = -1;
-               goto error;
+               goto error_accounting;
        }
 
        return ret;
 
+error_accounting:
+       lttng_ret = notification_thread_command_remove_tracer_event_source(
+                       the_notification_thread_handle,
+                       lttng_pipe_get_readfd(
+                                       app->event_notifier_group.event_pipe));
+       if (lttng_ret != LTTNG_OK) {
+               ERR("Failed to remove application tracer event source from notification thread");
+       }
+
 error:
        ustctl_release_object(app->sock, app->event_notifier_group.object);
        free(app->event_notifier_group.object);
@@ -5991,20 +6009,6 @@ void ust_app_global_update_all_event_notifier_rules(void)
        rcu_read_unlock();
 }
 
-void ust_app_update_event_notifier_error_count(struct lttng_trigger *trigger)
-{
-       uint64_t error_count = 0;
-       enum event_notifier_error_accounting_status status;
-       struct lttng_condition *condition = lttng_trigger_get_condition(trigger);
-
-       status = event_notifier_error_accounting_get_count(trigger, &error_count);
-       if (status != EVENT_NOTIFIER_ERROR_ACCOUNTING_STATUS_OK) {
-               ERR("Error getting trigger error count.");
-       }
-
-       lttng_condition_on_event_set_error_count(condition, error_count);
-}
-
 /*
  * Add context to a specific channel for global UST domain.
  */
@@ -7118,11 +7122,6 @@ enum lttng_error_code ust_app_rotate_session(struct ltt_session *session)
                        struct buffer_reg_channel *buf_reg_chan;
                        struct consumer_socket *socket;
 
-                       if (!reg->registry->reg.ust->metadata_key) {
-                               /* Skip since no metadata is present */
-                               continue;
-                       }
-
                        /* Get consumer socket to use to push the metadata.*/
                        socket = consumer_find_socket_by_bitness(reg->bits_per_long,
                                        usess->consumer);
@@ -7145,6 +7144,19 @@ enum lttng_error_code ust_app_rotate_session(struct ltt_session *session)
                                }
                        }
 
+                       /*
+                        * The metadata channel might not be present.
+                        *
+                        * Consumer stream allocation can be done
+                        * asynchronously and can fail on intermediary
+                        * operations (i.e add context) and lead to data
+                        * channels created with no metadata channel.
+                        */
+                       if (!reg->registry->reg.ust->metadata_key) {
+                               /* Skip since no metadata is present. */
+                               continue;
+                       }
+
                        (void) push_metadata(reg->registry->reg.ust, usess->consumer);
 
                        ret = consumer_rotate_channel(socket,
This page took 0.02559 seconds and 4 git commands to generate.