Fix: tests: fix unused-but-set warning in test_fd_tracker.c
[lttng-tools.git] / src / bin / lttng-sessiond / notification-thread-events.c
index 5cccc008efbc409fb3797590aaae22bcf6c1c823..a295739f2c3adc3be22cedee490de6e56ad5e163 100644 (file)
 #include <common/macros.h>
 #include <lttng/condition/condition.h>
 #include <lttng/action/action-internal.h>
-#include <lttng/action/group-internal.h>
+#include <lttng/action/list-internal.h>
 #include <lttng/domain-internal.h>
 #include <lttng/notification/notification-internal.h>
 #include <lttng/condition/condition-internal.h>
 #include <lttng/condition/buffer-usage-internal.h>
 #include <lttng/condition/session-consumed-size-internal.h>
 #include <lttng/condition/session-rotation-internal.h>
-#include <lttng/condition/on-event-internal.h>
+#include <lttng/condition/event-rule-matches-internal.h>
 #include <lttng/domain-internal.h>
 #include <lttng/notification/channel-internal.h>
 #include <lttng/trigger/trigger-internal.h>
@@ -36,7 +36,6 @@
 
 #include <time.h>
 #include <unistd.h>
-#include <assert.h>
 #include <inttypes.h>
 #include <fcntl.h>
 
@@ -311,7 +310,7 @@ int match_client_list_condition(struct cds_lfht_node *node, const void *key)
        struct notification_client_list *client_list;
        const struct lttng_condition *condition;
 
-       assert(condition_key);
+       LTTNG_ASSERT(condition_key);
 
        client_list = caa_container_of(node, struct notification_client_list,
                        notification_trigger_clients_ht_node);
@@ -373,7 +372,7 @@ int match_trigger_by_name_uid(struct cds_lfht_node *node,
                const void *key)
 {
        bool match = false;
-       const char *name;
+       const char *element_trigger_name;
        const char *key_name;
        enum lttng_trigger_status status;
        const struct lttng_credentials *key_creds;
@@ -385,14 +384,25 @@ int match_trigger_by_name_uid(struct cds_lfht_node *node,
                                struct lttng_trigger_ht_element,
                                node_by_name_uid);
 
-       status = lttng_trigger_get_name(trigger_ht_element->trigger, &name);
-       assert(status == LTTNG_TRIGGER_STATUS_OK);
+       status = lttng_trigger_get_name(trigger_ht_element->trigger,
+                       &element_trigger_name);
+       element_trigger_name = status == LTTNG_TRIGGER_STATUS_OK ?
+                       element_trigger_name : NULL;
 
        status = lttng_trigger_get_name(trigger_key, &key_name);
-       assert(status == LTTNG_TRIGGER_STATUS_OK);
+       key_name = status == LTTNG_TRIGGER_STATUS_OK ? key_name : NULL;
 
-       /* Compare the names. */
-       if (strcmp(name, key_name) != 0) {
+       /*
+        * Compare the names.
+        * Consider null names as not equal. This is to maintain backwards
+        * compatibility with pre-2.13 anonymous triggers. Multiples anonymous
+        * triggers are allowed for a given user.
+        */
+       if (!element_trigger_name || !key_name) {
+               goto end;
+       }
+
+       if (strcmp(element_trigger_name, key_name) != 0) {
                goto end;
        }
 
@@ -471,7 +481,7 @@ enum lttng_object_type get_condition_binding_object(
        case LTTNG_CONDITION_TYPE_SESSION_ROTATION_ONGOING:
        case LTTNG_CONDITION_TYPE_SESSION_ROTATION_COMPLETED:
                return LTTNG_OBJECT_TYPE_SESSION;
-       case LTTNG_CONDITION_TYPE_ON_EVENT:
+       case LTTNG_CONDITION_TYPE_EVENT_RULE_MATCHES:
                return LTTNG_OBJECT_TYPE_NONE;
        default:
                return LTTNG_OBJECT_TYPE_UNKNOWN;
@@ -515,11 +525,11 @@ void session_info_destroy(void *_data)
        struct session_info *session_info = _data;
        int ret;
 
-       assert(session_info);
+       LTTNG_ASSERT(session_info);
        if (session_info->channel_infos_ht) {
                ret = cds_lfht_destroy(session_info->channel_infos_ht, NULL);
                if (ret) {
-                       ERR("[notification-thread] Failed to destroy channel information hash table");
+                       ERR("Failed to destroy channel information hash table");
                }
        }
        lttng_session_trigger_list_destroy(session_info->trigger_list);
@@ -557,7 +567,7 @@ struct session_info *session_info_create(const char *name, uid_t uid, gid_t gid,
 {
        struct session_info *session_info;
 
-       assert(name);
+       LTTNG_ASSERT(name);
 
        session_info = zmalloc(sizeof(*session_info));
        if (!session_info) {
@@ -644,7 +654,6 @@ error:
        return NULL;
 }
 
-LTTNG_HIDDEN
 bool notification_client_list_get(struct notification_client_list *list)
 {
        return urcu_ref_get_unless_zero(&list->ref);
@@ -679,7 +688,7 @@ void notification_client_list_release(struct urcu_ref *list_ref)
                free(client_list_element);
        }
 
-       assert(cds_list_empty(&list->triggers_list));
+       LTTNG_ASSERT(cds_list_empty(&list->triggers_list));
 
        pthread_mutex_destroy(&list->lock);
        call_rcu(&list->rcu_node, free_notification_client_list_rcu);
@@ -841,7 +850,7 @@ int evaluate_channel_condition_for_client(
                                        lttng_trigger_get_const_condition(
                                                element->trigger);
 
-                       assert(current_condition);
+                       LTTNG_ASSERT(current_condition);
                        if (!lttng_condition_is_equal(condition,
                                        current_condition)) {
                                continue;
@@ -859,7 +868,7 @@ int evaluate_channel_condition_for_client(
 
        if (!channel_key){
                /* No channel found; normal exit. */
-               DBG("[notification-thread] No known channel associated with newly subscribed-to condition");
+               DBG("No known channel associated with newly subscribed-to condition");
                ret = 0;
                goto end;
        }
@@ -871,7 +880,7 @@ int evaluate_channel_condition_for_client(
                        channel_key,
                        &iter);
        node = cds_lfht_iter_get_node(&iter);
-       assert(node);
+       LTTNG_ASSERT(node);
        channel_info = caa_container_of(node, struct channel_info,
                        channels_ht_node);
 
@@ -888,7 +897,7 @@ int evaluate_channel_condition_for_client(
                                channel_state_ht_node);
        } else {
                /* Nothing to evaluate, no sample was ever taken. Normal exit */
-               DBG("[notification-thread] No channel sample associated with newly subscribed-to condition");
+               DBG("No channel sample associated with newly subscribed-to condition");
                ret = 0;
                goto end;
        }
@@ -898,7 +907,7 @@ int evaluate_channel_condition_for_client(
                        0, channel_info->session_info->consumed_data_size,
                        channel_info);
        if (ret) {
-               WARN("[notification-thread] Fatal error occurred while evaluating a newly subscribed-to condition");
+               WARN("Fatal error occurred while evaluating a newly subscribed-to condition");
                goto end;
        }
 
@@ -934,7 +943,7 @@ const char *get_condition_session_name(const struct lttng_condition *condition)
                abort();
        }
        if (status != LTTNG_CONDITION_STATUS_OK) {
-               ERR("[notification-thread] Failed to retrieve session rotation condition's session name");
+               ERR("Failed to retrieve session rotation condition's session name");
                goto end;
        }
 end:
@@ -965,7 +974,7 @@ int evaluate_session_condition_for_client(
                        &iter);
        node = cds_lfht_iter_get_node(&iter);
        if (!node) {
-               DBG("[notification-thread] No known session matching name \"%s\"",
+               DBG("No known session matching name \"%s\"",
                                session_name);
                ret = 0;
                goto end;
@@ -990,7 +999,7 @@ int evaluate_session_condition_for_client(
                                session_info->rotation.id);
                if (!*evaluation) {
                        /* Fatal error. */
-                       ERR("[notification-thread] Failed to create session rotation ongoing evaluation for session \"%s\"",
+                       ERR("Failed to create session rotation ongoing evaluation for session \"%s\"",
                                        session_info->name);
                        ret = -1;
                        goto end_session_put;
@@ -1027,10 +1036,10 @@ int evaluate_condition_for_client(const struct lttng_trigger *trigger,
        uid_t object_uid = 0;
        gid_t object_gid = 0;
 
-       assert(trigger);
-       assert(condition);
-       assert(client);
-       assert(state);
+       LTTNG_ASSERT(trigger);
+       LTTNG_ASSERT(condition);
+       LTTNG_ASSERT(client);
+       LTTNG_ASSERT(state);
 
        switch (get_condition_binding_object(condition)) {
        case LTTNG_OBJECT_TYPE_SESSION:
@@ -1042,7 +1051,7 @@ int evaluate_condition_for_client(const struct lttng_trigger *trigger,
                                &evaluation, &object_uid, &object_gid);
                break;
        case LTTNG_OBJECT_TYPE_NONE:
-               DBG("[notification-thread] Newly subscribed-to condition not bound to object, nothing to evaluate");
+               DBG("Newly subscribed-to condition not bound to object, nothing to evaluate");
                ret = 0;
                goto end;
        case LTTNG_OBJECT_TYPE_UNKNOWN:
@@ -1056,7 +1065,7 @@ int evaluate_condition_for_client(const struct lttng_trigger *trigger,
        }
        if (!evaluation) {
                /* Evaluation yielded nothing. Normal exit. */
-               DBG("[notification-thread] Newly subscribed-to condition evaluated to false, nothing to report to client");
+               DBG("Newly subscribed-to condition evaluated to false, nothing to report to client");
                ret = 0;
                goto end;
        }
@@ -1073,7 +1082,7 @@ int evaluate_condition_for_client(const struct lttng_trigger *trigger,
        cds_list_add(&client_list_element.node, &client_list.clients_list);
 
        /* Send evaluation result to the newly-subscribed client. */
-       DBG("[notification-thread] Newly subscribed-to condition evaluated to true, notifying client");
+       DBG("Newly subscribed-to condition evaluated to true, notifying client");
        ret = send_evaluation_to_clients(trigger, evaluation, &client_list,
                        state, object_uid, object_gid);
 
@@ -1123,9 +1132,11 @@ int notification_thread_client_subscribe(struct notification_client *client,
         */
        CDS_INIT_LIST_HEAD(&condition_list_element->node);
        condition_list_element->condition = condition;
+       condition = NULL;
        cds_list_add(&condition_list_element->node, &client->condition_list);
 
-       client_list = get_client_list_from_condition(state, condition);
+       client_list = get_client_list_from_condition(
+                       state, condition_list_element->condition);
        if (!client_list) {
                /*
                 * No notification-emiting trigger registered with this
@@ -1149,9 +1160,9 @@ int notification_thread_client_subscribe(struct notification_client *client,
        pthread_mutex_lock(&client_list->lock);
        cds_list_for_each_entry(trigger_ht_element,
                        &client_list->triggers_list, client_list_trigger_node) {
-               if (evaluate_condition_for_client(trigger_ht_element->trigger, condition,
+               if (evaluate_condition_for_client(trigger_ht_element->trigger, condition_list_element->condition,
                                client, state)) {
-                       WARN("[notification-thread] Evaluation of a condition on client subscription failed, aborting.");
+                       WARN("Evaluation of a condition on client subscription failed, aborting.");
                        ret = -1;
                        free(client_list_element);
                        pthread_mutex_unlock(&client_list->lock);
@@ -1178,10 +1189,12 @@ end:
        if (client_list) {
                notification_client_list_put(client_list);
        }
+       lttng_condition_destroy(condition);
        return ret;
 error:
        free(condition_list_element);
        free(client_list_element);
+       lttng_condition_destroy(condition);
        return ret;
 }
 
@@ -1356,18 +1369,18 @@ bool buffer_usage_condition_applies_to_channel(
 
        status = lttng_condition_buffer_usage_get_domain_type(condition,
                        &condition_domain);
-       assert(status == LTTNG_CONDITION_STATUS_OK);
+       LTTNG_ASSERT(status == LTTNG_CONDITION_STATUS_OK);
        if (channel_info->key.domain != condition_domain) {
                goto fail;
        }
 
        status = lttng_condition_buffer_usage_get_session_name(
                        condition, &condition_session_name);
-       assert((status == LTTNG_CONDITION_STATUS_OK) && condition_session_name);
+       LTTNG_ASSERT((status == LTTNG_CONDITION_STATUS_OK) && condition_session_name);
 
        status = lttng_condition_buffer_usage_get_channel_name(
                        condition, &condition_channel_name);
-       assert((status == LTTNG_CONDITION_STATUS_OK) && condition_channel_name);
+       LTTNG_ASSERT((status == LTTNG_CONDITION_STATUS_OK) && condition_channel_name);
 
        if (strcmp(channel_info->session_info->name, condition_session_name)) {
                goto fail;
@@ -1391,7 +1404,7 @@ bool session_consumed_size_condition_applies_to_channel(
 
        status = lttng_condition_session_consumed_size_get_session_name(
                        condition, &condition_session_name);
-       assert((status == LTTNG_CONDITION_STATUS_OK) && condition_session_name);
+       LTTNG_ASSERT((status == LTTNG_CONDITION_STATUS_OK) && condition_session_name);
 
        if (strcmp(channel_info->session_info->name, condition_session_name)) {
                goto fail;
@@ -1454,7 +1467,7 @@ struct lttng_session_trigger_list *get_session_trigger_list(
                 * Not an error, the list of triggers applying to that session
                 * will be initialized when the session is created.
                 */
-               DBG("[notification-thread] No trigger list found for session \"%s\" as it is not yet known to the notification system",
+               DBG("No trigger list found for session \"%s\" as it is not yet known to the notification system",
                                session_name);
                goto end;
        }
@@ -1563,11 +1576,11 @@ bool trigger_applies_to_session(const struct lttng_trigger *trigger,
                condition_status = lttng_condition_session_rotation_get_session_name(
                        condition, &condition_session_name);
                if (condition_status != LTTNG_CONDITION_STATUS_OK) {
-                       ERR("[notification-thread] Failed to retrieve session rotation condition's session name");
+                       ERR("Failed to retrieve session rotation condition's session name");
                        goto end;
                }
 
-               assert(condition_session_name);
+               LTTNG_ASSERT(condition_session_name);
                applies = !strcmp(condition_session_name, session_name);
                break;
        }
@@ -1618,7 +1631,7 @@ struct lttng_session_trigger_list *lttng_session_trigger_list_build(
                trigger_count++;
        }
 
-       DBG("[notification-thread] Found %i triggers that apply to newly created session",
+       DBG("Found %i triggers that apply to newly created session",
                        trigger_count);
        return session_trigger_list;
 error:
@@ -1644,12 +1657,12 @@ struct session_info *find_or_create_session_info(
                        &iter);
        node = cds_lfht_iter_get_node(&iter);
        if (node) {
-               DBG("[notification-thread] Found session info of session \"%s\" (uid = %i, gid = %i)",
+               DBG("Found session info of session \"%s\" (uid = %i, gid = %i)",
                                name, uid, gid);
                session = caa_container_of(node, struct session_info,
                                sessions_ht_node);
-               assert(session->uid == uid);
-               assert(session->gid == gid);
+               LTTNG_ASSERT(session->uid == uid);
+               LTTNG_ASSERT(session->gid == gid);
                session_info_get(session);
                goto end;
        }
@@ -1662,7 +1675,7 @@ struct session_info *find_or_create_session_info(
        session = session_info_create(name, uid, gid, trigger_list,
                        state->sessions_ht);
        if (!session) {
-               ERR("[notification-thread] Failed to allocation session info for session \"%s\" (uid = %i, gid = %i)",
+               ERR("Failed to allocation session info for session \"%s\" (uid = %i, gid = %i)",
                                name, uid, gid);
                lttng_session_trigger_list_destroy(trigger_list);
                goto error;
@@ -1700,7 +1713,7 @@ int handle_notification_thread_command_add_channel(
        struct cds_lfht_iter iter;
        struct session_info *session_info = NULL;
 
-       DBG("[notification-thread] Adding channel %s from session %s, channel key = %" PRIu64 " in %s domain",
+       DBG("Adding channel %s from session %s, channel key = %" PRIu64 " in %s domain",
                        channel_name, session_name, channel_key_int,
                        lttng_domain_type_str(channel_domain));
 
@@ -1742,7 +1755,7 @@ int handle_notification_thread_command_add_channel(
        }
        rcu_read_unlock();
 
-       DBG("[notification-thread] Found %i triggers that apply to newly added channel",
+       DBG("Found %i triggers that apply to newly added channel",
                        trigger_count);
        channel_trigger_list = zmalloc(sizeof(*channel_trigger_list));
        if (!channel_trigger_list) {
@@ -1802,7 +1815,7 @@ int handle_notification_thread_command_remove_channel(
        struct channel_key key = { .key = channel_key, .domain = domain };
        struct channel_info *channel_info;
 
-       DBG("[notification-thread] Removing channel key = %" PRIu64 " in %s domain",
+       DBG("Removing channel key = %" PRIu64 " in %s domain",
                        channel_key, lttng_domain_type_str(domain));
 
        rcu_read_lock();
@@ -1818,7 +1831,7 @@ int handle_notification_thread_command_remove_channel(
         * channel that doesn't exist.
         */
        if (!node) {
-               ERR("[notification-thread] Channel being removed is unknown to the notification thread");
+               ERR("Channel being removed is unknown to the notification thread");
                goto end;
        }
 
@@ -1860,7 +1873,7 @@ int handle_notification_thread_command_remove_channel(
                        &key,
                        &iter);
        node = cds_lfht_iter_get_node(&iter);
-       assert(node);
+       LTTNG_ASSERT(node);
        channel_info = caa_container_of(node, struct channel_info,
                        channels_ht_node);
        cds_lfht_del(state->channels_ht, node);
@@ -1906,7 +1919,7 @@ int handle_notification_thread_command_session_rotation(
        session_info->rotation.id = trace_archive_chunk_id;
        trigger_list = get_session_trigger_list(state, session_name);
        if (!trigger_list) {
-               DBG("[notification-thread] No triggers applying to session \"%s\" found",
+               DBG("No triggers applying to session \"%s\" found",
                                session_name);
                goto end;
        }
@@ -1922,7 +1935,7 @@ int handle_notification_thread_command_session_rotation(
 
                trigger = trigger_list_element->trigger;
                condition = lttng_trigger_get_const_condition(trigger);
-               assert(condition);
+               LTTNG_ASSERT(condition);
                condition_type = lttng_condition_get_type(condition);
 
                if (condition_type == LTTNG_CONDITION_TYPE_SESSION_ROTATION_ONGOING &&
@@ -2019,14 +2032,14 @@ int handle_notification_thread_command_add_tracer_event_source(
 
        cds_list_add(&element->node, &state->tracer_event_sources_list);
 
-       DBG3("[notification-thread] Adding tracer event source fd to poll set: tracer_event_source_fd = %d, domain = '%s'",
+       DBG3("Adding tracer event source fd to poll set: tracer_event_source_fd = %d, domain = '%s'",
                        tracer_event_source_fd,
                        lttng_domain_type_str(domain_type));
 
        /* Adding the read side pipe to the event poll. */
        ret = lttng_poll_add(&state->events, tracer_event_source_fd, LPOLLIN | LPOLLERR);
        if (ret < 0) {
-               ERR("[notification-thread] Failed to add tracer event source to poll set: tracer_event_source_fd = %d, domain = '%s'",
+               ERR("Failed to add tracer event source to poll set: tracer_event_source_fd = %d, domain = '%s'",
                                tracer_event_source_fd,
                                lttng_domain_type_str(element->domain));
                cds_list_del(&element->node);
@@ -2051,13 +2064,13 @@ int drain_event_notifier_notification_pipe(
 
        ret = lttng_poll_create(&events, 1, LTTNG_CLOEXEC);
        if (ret < 0) {
-               ERR("[notification-thread] Error creating lttng_poll_event");
+               ERR("Error creating lttng_poll_event");
                goto end;
        }
 
        ret = lttng_poll_add(&events, pipe, LPOLLIN);
        if (ret < 0) {
-               ERR("[notification-thread] Error adding fd event notifier notification pipe to lttng_poll_event: fd = %d",
+               ERR("Error adding fd event notifier notification pipe to lttng_poll_event: fd = %d",
                                pipe);
                goto end;
        }
@@ -2085,7 +2098,7 @@ int drain_event_notifier_notification_pipe(
 
                ret = handle_one_event_notifier_notification(state, pipe, domain);
                if (ret) {
-                       ERR("[notification-thread] Error consuming an event notifier notification from pipe: fd = %d",
+                       ERR("Error consuming an event notifier notification from pipe: fd = %d",
                                        pipe);
                }
        }
@@ -2095,129 +2108,121 @@ end:
 }
 
 static
-int handle_notification_thread_command_remove_tracer_event_source(
-               struct notification_thread_state *state,
-               int tracer_event_source_fd,
-               enum lttng_error_code *_cmd_result)
+struct notification_event_tracer_event_source_element *
+find_tracer_event_source_element(struct notification_thread_state *state,
+               int tracer_event_source_fd)
 {
-       int ret = 0;
-       bool found = false;
-       enum lttng_error_code cmd_result = LTTNG_OK;
-       struct notification_event_tracer_event_source_element *source_element = NULL, *tmp;
+       struct notification_event_tracer_event_source_element *source_element;
 
-       cds_list_for_each_entry_safe(source_element, tmp,
+       cds_list_for_each_entry(source_element,
                        &state->tracer_event_sources_list, node) {
-               if (source_element->fd != tracer_event_source_fd) {
-                       continue;
+               if (source_element->fd == tracer_event_source_fd) {
+                       goto end;
                }
-
-               DBG("[notification-thread] Removed tracer event source from poll set: tracer_event_source_fd = %d, domain = '%s'",
-                               tracer_event_source_fd,
-                               lttng_domain_type_str(source_element->domain));
-               cds_list_del(&source_element->node);
-               found = true;
-               break;
        }
 
-       if (!found) {
-               /*
-                * This is temporarily allowed since the poll activity set is
-                * not properly cleaned-up for the moment. This is adressed in
-                * an upcoming fix.
-                */
-               source_element = NULL;
-               goto end;
-       }
+       source_element = NULL;
+end:
+       return source_element;
+}
 
-       if (!source_element->is_fd_in_poll_set) {
-               /* Skip the poll set removal. */
-               goto end;
-       }
+static
+int remove_tracer_event_source_from_pollset(
+               struct notification_thread_state *state,
+               struct notification_event_tracer_event_source_element *source_element)
+{
+       int ret = 0;
 
-       DBG3("[notification-thread] Removing tracer event source from poll set: tracer_event_source_fd = %d, domain = '%s'",
-                       tracer_event_source_fd,
+       LTTNG_ASSERT(source_element->is_fd_in_poll_set);
+
+       DBG3("Removing tracer event source from poll set: tracer_event_source_fd = %d, domain = '%s'",
+                       source_element->fd,
                        lttng_domain_type_str(source_element->domain));
 
        /* Removing the fd from the event poll set. */
-       ret = lttng_poll_del(&state->events, tracer_event_source_fd);
+       ret = lttng_poll_del(&state->events, source_element->fd);
        if (ret < 0) {
-               ERR("[notification-thread] Failed to remove tracer event source from poll set: tracer_event_source_fd = %d, domain = '%s'",
-                               tracer_event_source_fd,
+               ERR("Failed to remove tracer event source from poll set: tracer_event_source_fd = %d, domain = '%s'",
+                               source_element->fd,
                                lttng_domain_type_str(source_element->domain));
-               cmd_result = LTTNG_ERR_FATAL;
+               ret = -1;
                goto end;
        }
 
        source_element->is_fd_in_poll_set = false;
 
-       ret = drain_event_notifier_notification_pipe(state, tracer_event_source_fd,
+       /*
+        * Force the notification thread to restart the poll() loop to ensure
+        * that any events from the removed fd are removed.
+        */
+       state->restart_poll = true;
+
+       ret = drain_event_notifier_notification_pipe(state, source_element->fd,
                        source_element->domain);
        if (ret) {
-               ERR("[notification-thread] Error draining event notifier notification: tracer_event_source_fd = %d, domain = %s",
-                               tracer_event_source_fd,
+               ERR("Error draining event notifier notification: tracer_event_source_fd = %d, domain = %s",
+                               source_element->fd,
                                lttng_domain_type_str(source_element->domain));
-               cmd_result = LTTNG_ERR_FATAL;
+               ret = -1;
                goto end;
        }
 
-       /*
-        * The drain_event_notifier_notification_pipe() call might have read
-        * data from an fd that we received in event in the latest _poll_wait()
-        * call. Make sure the thread call poll_wait() again to ensure we have
-        * a clean state.
-        */
-       state->restart_poll = true;
-
 end:
-       free(source_element);
-       *_cmd_result = cmd_result;
        return ret;
 }
 
-static
-int condition_on_event_update_error_count(struct lttng_trigger *trigger)
+int handle_notification_thread_tracer_event_source_died(
+               struct notification_thread_state *state,
+               int tracer_event_source_fd)
 {
        int ret = 0;
-       uint64_t error_count = 0;
-       struct lttng_condition *condition;
-       enum event_notifier_error_accounting_status status;
+       struct notification_event_tracer_event_source_element *source_element;
 
-       condition = lttng_trigger_get_condition(trigger);
-       assert(lttng_condition_get_type(condition) ==
-                       LTTNG_CONDITION_TYPE_ON_EVENT);
-
-       status = event_notifier_error_accounting_get_count(trigger, &error_count);
-       if (status != EVENT_NOTIFIER_ERROR_ACCOUNTING_STATUS_OK) {
-               uid_t trigger_owner_uid;
-               const char *trigger_name;
-               const enum lttng_trigger_status trigger_status =
-                               lttng_trigger_get_owner_uid(
-                                               trigger, &trigger_owner_uid);
-
-               assert(trigger_status == LTTNG_TRIGGER_STATUS_OK);
-               if (lttng_trigger_get_name(trigger, &trigger_name) != LTTNG_TRIGGER_STATUS_OK) {
-                       trigger_name = "(unnamed)";
-               }
+       source_element = find_tracer_event_source_element(state,
+                       tracer_event_source_fd);
 
-               ERR("Failed to get event notifier error count of trigger for update: trigger owner = %d, trigger name = '%s'",
-                               trigger_owner_uid, trigger_name);
-               ret = -1;
+       LTTNG_ASSERT(source_element);
+
+       ret = remove_tracer_event_source_from_pollset(state, source_element);
+       if (ret) {
+               ERR("Failed to remove dead tracer event source from poll set");
        }
 
-       lttng_condition_on_event_set_error_count(condition, error_count);
        return ret;
 }
 
-int handle_notification_thread_remove_tracer_event_source_no_result(
+static
+int handle_notification_thread_command_remove_tracer_event_source(
                struct notification_thread_state *state,
-               int tracer_event_source_fd)
+               int tracer_event_source_fd,
+               enum lttng_error_code *_cmd_result)
 {
-       int ret;
-       enum lttng_error_code cmd_result;
+       int ret = 0;
+       enum lttng_error_code cmd_result = LTTNG_OK;
+       struct notification_event_tracer_event_source_element *source_element = NULL;
+
+       source_element = find_tracer_event_source_element(state,
+                       tracer_event_source_fd);
 
-       ret = handle_notification_thread_command_remove_tracer_event_source(
-                       state, tracer_event_source_fd, &cmd_result);
-       (void) cmd_result;
+       LTTNG_ASSERT(source_element);
+
+       /* Remove the tracer source from the list. */
+       cds_list_del(&source_element->node);
+
+       if (!source_element->is_fd_in_poll_set) {
+               /* Skip the poll set removal. */
+               goto end;
+       }
+
+       ret = remove_tracer_event_source_from_pollset(state, source_element);
+       if (ret) {
+               ERR("Failed to remove tracer event source from poll set");
+               cmd_result = LTTNG_ERR_FATAL;
+       }
+
+end:
+       free(source_element);
+       *_cmd_result = cmd_result;
        return ret;
 }
 
@@ -2255,12 +2260,6 @@ static int handle_notification_thread_command_list_triggers(
                        continue;
                }
 
-               if (lttng_trigger_needs_tracer_notifier(trigger_ht_element->trigger)) {
-                       ret = condition_on_event_update_error_count(
-                                       trigger_ht_element->trigger);
-                       assert(!ret);
-               }
-
                ret = lttng_triggers_add(local_triggers,
                                trigger_ht_element->trigger);
                if (ret < 0) {
@@ -2293,7 +2292,7 @@ static inline void get_trigger_info_for_log(const struct lttng_trigger *trigger,
        case LTTNG_TRIGGER_STATUS_OK:
                break;
        case LTTNG_TRIGGER_STATUS_UNSET:
-               *trigger_name = "(unset)";
+               *trigger_name = "(anonymous)";
                break;
        default:
                abort();
@@ -2301,7 +2300,7 @@ static inline void get_trigger_info_for_log(const struct lttng_trigger *trigger,
 
        trigger_status = lttng_trigger_get_owner_uid(trigger,
                        trigger_owner_uid);
-       assert(trigger_status == LTTNG_TRIGGER_STATUS_OK);
+       LTTNG_ASSERT(trigger_status == LTTNG_TRIGGER_STATUS_OK);
 }
 
 static int handle_notification_thread_command_get_trigger(
@@ -2334,7 +2333,7 @@ static int handle_notification_thread_command_get_trigger(
 
        /* Not a fatal error if the trigger is not found. */
        get_trigger_info_for_log(trigger, &trigger_name, &trigger_owner_uid);
-       ERR("Failed to retrieve registered version of trigger: trigger name = '%s', trigger owner uid = %d",
+       DBG("Failed to retrieve registered version of trigger: trigger name = '%s', trigger owner uid = %d",
                        trigger_name, (int) trigger_owner_uid);
 
        ret = 0;
@@ -2359,7 +2358,7 @@ bool condition_is_supported(struct lttng_condition *condition)
 
                ret = lttng_condition_buffer_usage_get_domain_type(condition,
                                &domain);
-               assert(ret == 0);
+               LTTNG_ASSERT(ret == 0);
 
                if (domain != LTTNG_DOMAIN_KERNEL) {
                        is_supported = true;
@@ -2376,15 +2375,15 @@ bool condition_is_supported(struct lttng_condition *condition)
                is_supported = kernel_supports_ring_buffer_snapshot_sample_positions() == 1;
                break;
        }
-       case LTTNG_CONDITION_TYPE_ON_EVENT:
+       case LTTNG_CONDITION_TYPE_EVENT_RULE_MATCHES:
        {
                const struct lttng_event_rule *event_rule;
                enum lttng_domain_type domain;
                const enum lttng_condition_status status =
-                               lttng_condition_on_event_get_rule(
+                               lttng_condition_event_rule_matches_get_rule(
                                                condition, &event_rule);
 
-               assert(status == LTTNG_CONDITION_STATUS_OK);
+               LTTNG_ASSERT(status == LTTNG_CONDITION_STATUS_OK);
 
                domain = lttng_event_rule_get_domain_type(event_rule);
                if (domain != LTTNG_DOMAIN_KERNEL) {
@@ -2429,7 +2428,7 @@ int bind_trigger_to_matching_session(struct lttng_trigger *trigger,
                status = lttng_condition_session_rotation_get_session_name(
                                condition, &session_name);
                if (status != LTTNG_CONDITION_STATUS_OK) {
-                       ERR("[notification-thread] Failed to bind trigger to session: unable to get 'session_rotation' condition's session name");
+                       ERR("Failed to bind trigger to session: unable to get 'session_rotation' condition's session name");
                        ret = -1;
                        goto end;
                }
@@ -2442,13 +2441,13 @@ int bind_trigger_to_matching_session(struct lttng_trigger *trigger,
 
        trigger_list = get_session_trigger_list(state, session_name);
        if (!trigger_list) {
-               DBG("[notification-thread] Unable to bind trigger applying to session \"%s\" as it is not yet known to the notification system",
+               DBG("Unable to bind trigger applying to session \"%s\" as it is not yet known to the notification system",
                                session_name);
                goto end;
 
        }
 
-       DBG("[notification-thread] Newly registered trigger bound to session \"%s\"",
+       DBG("Newly registered trigger bound to session \"%s\"",
                        session_name);
        ret = lttng_session_trigger_list_add(trigger_list, trigger);
 end:
@@ -2481,7 +2480,7 @@ int bind_trigger_to_matching_channels(struct lttng_trigger *trigger,
                                &channel->key,
                                &lookup_iter);
                node = cds_lfht_iter_get_node(&lookup_iter);
-               assert(node);
+               LTTNG_ASSERT(node);
                trigger_list = caa_container_of(node,
                                struct lttng_channel_trigger_list,
                                channel_triggers_ht_node);
@@ -2494,7 +2493,7 @@ int bind_trigger_to_matching_channels(struct lttng_trigger *trigger,
                CDS_INIT_LIST_HEAD(&trigger_list_element->node);
                trigger_list_element->trigger = trigger;
                cds_list_add(&trigger_list_element->node, &trigger_list->list);
-               DBG("[notification-thread] Newly registered trigger bound to channel \"%s\"",
+               DBG("Newly registered trigger bound to channel \"%s\"",
                                channel->name);
        }
 end:
@@ -2511,21 +2510,21 @@ bool is_trigger_action_notify(const struct lttng_trigger *trigger)
                        lttng_trigger_get_const_action(trigger);
        enum lttng_action_type action_type;
 
-       assert(action);
+       LTTNG_ASSERT(action);
        action_type = lttng_action_get_type(action);
        if (action_type == LTTNG_ACTION_TYPE_NOTIFY) {
                is_notify = true;
                goto end;
-       } else if (action_type != LTTNG_ACTION_TYPE_GROUP) {
+       } else if (action_type != LTTNG_ACTION_TYPE_LIST) {
                goto end;
        }
 
-       action_status = lttng_action_group_get_count(action, &count);
-       assert(action_status == LTTNG_ACTION_STATUS_OK);
+       action_status = lttng_action_list_get_count(action, &count);
+       LTTNG_ASSERT(action_status == LTTNG_ACTION_STATUS_OK);
 
        for (i = 0; i < count; i++) {
                const struct lttng_action *inner_action =
-                               lttng_action_group_get_at_index(
+                               lttng_action_list_get_at_index(
                                                action, i);
 
                action_type = lttng_action_get_type(inner_action);
@@ -2575,7 +2574,7 @@ enum lttng_error_code generate_trigger_name(
                }
 
                status = lttng_trigger_get_name(trigger, name);
-               assert(status == LTTNG_TRIGGER_STATUS_OK);
+               LTTNG_ASSERT(status == LTTNG_TRIGGER_STATUS_OK);
 
                taken = trigger_name_taken(state, trigger);
        } while (taken || state->trigger_id.name_offset == UINT64_MAX);
@@ -2588,8 +2587,8 @@ void notif_thread_state_remove_trigger_ht_elem(
                struct notification_thread_state *state,
                struct lttng_trigger_ht_element *trigger_ht_element)
 {
-       assert(state);
-       assert(trigger_ht_element);
+       LTTNG_ASSERT(state);
+       LTTNG_ASSERT(trigger_ht_element);
 
        cds_lfht_del(state->triggers_ht, &trigger_ht_element->node);
        cds_lfht_del(state->triggers_by_name_uid_ht, &trigger_ht_element->node_by_name_uid);
@@ -2632,7 +2631,7 @@ enum lttng_error_code setup_tracer_notifier(
                        trigger, &error_counter_index);
        if (error_accounting_status != EVENT_NOTIFIER_ERROR_ACCOUNTING_STATUS_OK) {
                if (error_accounting_status == EVENT_NOTIFIER_ERROR_ACCOUNTING_STATUS_NO_INDEX_AVAILABLE) {
-                       DBG("Trigger group error accounting counter full.");
+                       DBG("Trigger list error accounting counter full.");
                        ret = LTTNG_ERR_EVENT_NOTIFIER_ERROR_ACCOUNTING_FULL;
                } else {
                        ERR("Error registering trigger for error accounting");
@@ -2642,7 +2641,7 @@ enum lttng_error_code setup_tracer_notifier(
                goto error_remove_ht_element;
        }
 
-       lttng_condition_on_event_set_error_counter_index(
+       lttng_condition_event_rule_matches_set_error_counter_index(
                        condition, error_counter_index);
 
        ret = LTTNG_OK;
@@ -2675,6 +2674,7 @@ static
 int handle_notification_thread_command_register_trigger(
                struct notification_thread_state *state,
                struct lttng_trigger *trigger,
+               bool is_trigger_anonymous,
                enum lttng_error_code *cmd_result)
 {
        int ret = 0;
@@ -2697,26 +2697,31 @@ int handle_notification_thread_command_register_trigger(
        /* Set the trigger's tracer token. */
        lttng_trigger_set_tracer_token(trigger, trigger_tracer_token);
 
-       if (lttng_trigger_get_name(trigger, &trigger_name) ==
-                       LTTNG_TRIGGER_STATUS_UNSET) {
-               const enum lttng_error_code ret_code = generate_trigger_name(
-                               state, trigger, &trigger_name);
+       if (!is_trigger_anonymous) {
+               if (lttng_trigger_get_name(trigger, &trigger_name) ==
+                               LTTNG_TRIGGER_STATUS_UNSET) {
+                       const enum lttng_error_code ret_code =
+                                       generate_trigger_name(state, trigger,
+                                                       &trigger_name);
 
-               if (ret_code != LTTNG_OK) {
-                       /* Fatal error. */
-                       ret = -1;
-                       *cmd_result = ret_code;
+                       if (ret_code != LTTNG_OK) {
+                               /* Fatal error. */
+                               ret = -1;
+                               *cmd_result = ret_code;
+                               goto error;
+                       }
+               } else if (trigger_name_taken(state, trigger)) {
+                       /* Not a fatal error. */
+                       *cmd_result = LTTNG_ERR_TRIGGER_EXISTS;
+                       ret = 0;
                        goto error;
                }
-       } else if (trigger_name_taken(state, trigger)) {
-               /* Not a fatal error. */
-               *cmd_result = LTTNG_ERR_TRIGGER_EXISTS;
-               ret = 0;
-               goto error;
+       } else {
+               trigger_name = "(anonymous)";
        }
 
        condition = lttng_trigger_get_condition(trigger);
-       assert(condition);
+       LTTNG_ASSERT(condition);
 
        /* Some conditions require tracers to implement a minimal ABI version. */
        if (!condition_is_supported(condition)) {
@@ -2752,9 +2757,8 @@ int handle_notification_thread_command_register_trigger(
                        trigger,
                        &trigger_ht_element->node_by_name_uid);
        if (node != &trigger_ht_element->node_by_name_uid) {
-               /* Not a fatal error, simply report it to the client. */
-               cds_lfht_del(state->triggers_ht, &trigger_ht_element->node);
-               *cmd_result = LTTNG_ERR_TRIGGER_EXISTS;
+               /* Internal error: add to triggers_ht should have failed. */
+               ret = -1;
                goto error_free_ht_element;
        }
 
@@ -3005,7 +3009,7 @@ void teardown_tracer_notifier(struct notification_thread_state *state,
                                trigger_tokens_ht_element->trigger);
 
                /* TODO talk to all app and remove it */
-               DBG("[notification-thread] Removed trigger from tokens_ht");
+               DBG("Removed trigger from tokens_ht");
                cds_lfht_del(state->trigger_tokens_ht,
                                &trigger_tokens_ht_element->node);
 
@@ -3060,7 +3064,7 @@ int handle_notification_thread_command_unregister_trigger(
                                continue;
                        }
 
-                       DBG("[notification-thread] Removed trigger from channel_triggers_ht");
+                       DBG("Removed trigger from channel_triggers_ht");
                        cds_list_del(&trigger_element->node);
                        /* A trigger can only appear once per channel */
                        break;
@@ -3077,7 +3081,7 @@ int handle_notification_thread_command_unregister_trigger(
                 * notification_trigger_clients_ht.
                 */
                client_list = get_client_list_from_condition(state, condition);
-               assert(client_list);
+               LTTNG_ASSERT(client_list);
 
                pthread_mutex_lock(&client_list->lock);
                cds_list_del(&trigger_ht_element->client_list_trigger_node);
@@ -3125,12 +3129,13 @@ int handle_notification_thread_command(
        cds_list_del(&cmd->cmd_list_node);
        pthread_mutex_unlock(&handle->cmd_queue.lock);
 
-       DBG("[notification-thread] Received `%s` command",
+       DBG("Received `%s` command",
                        notification_command_type_str(cmd->type));
        switch (cmd->type) {
        case NOTIFICATION_COMMAND_TYPE_REGISTER_TRIGGER:
                ret = handle_notification_thread_command_register_trigger(state,
                                cmd->parameters.register_trigger.trigger,
+                               cmd->parameters.register_trigger.is_trigger_anonymous,
                                &cmd->reply_code);
                break;
        case NOTIFICATION_COMMAND_TYPE_UNREGISTER_TRIGGER:
@@ -3239,7 +3244,7 @@ int handle_notification_thread_command(
                break;
        }
        default:
-               ERR("[notification-thread] Unknown internal command received");
+               ERR("Unknown internal command received");
                goto error_unlock;
        }
 
@@ -3313,7 +3318,7 @@ int handle_notification_thread_client_connect(
        int ret;
        struct notification_client *client;
 
-       DBG("[notification-thread] Handling new notification channel client connection");
+       DBG("Handling new notification channel client connection");
 
        client = zmalloc(sizeof(*client));
        if (!client) {
@@ -3331,14 +3336,14 @@ int handle_notification_thread_client_connect(
 
        ret = client_reset_inbound_state(client);
        if (ret) {
-               ERR("[notification-thread] Failed to reset client communication's inbound state");
+               ERR("Failed to reset client communication's inbound state");
                ret = 0;
                goto error;
        }
 
        ret = lttcomm_accept_unix_sock(state->notification_channel_socket);
        if (ret < 0) {
-               ERR("[notification-thread] Failed to accept new notification channel client connection");
+               ERR("Failed to accept new notification channel client connection");
                ret = 0;
                goto error;
        }
@@ -3347,13 +3352,13 @@ int handle_notification_thread_client_connect(
 
        ret = socket_set_non_blocking(client->socket);
        if (ret) {
-               ERR("[notification-thread] Failed to set new notification channel client connection socket as non-blocking");
+               ERR("Failed to set new notification channel client connection socket as non-blocking");
                goto error;
        }
 
        ret = lttcomm_setsockopt_creds_unix_sock(client->socket);
        if (ret < 0) {
-               ERR("[notification-thread] Failed to set socket options on new notification channel client socket");
+               ERR("Failed to set socket options on new notification channel client socket");
                ret = 0;
                goto error;
        }
@@ -3362,11 +3367,11 @@ int handle_notification_thread_client_connect(
                        LPOLLIN | LPOLLERR |
                        LPOLLHUP | LPOLLRDHUP);
        if (ret < 0) {
-               ERR("[notification-thread] Failed to add notification channel client socket to poll set");
+               ERR("Failed to add notification channel client socket to poll set");
                ret = 0;
                goto error;
        }
-       DBG("[notification-thread] Added new notification channel client socket (%i) to poll set",
+       DBG("Added new notification channel client socket (%i) to poll set",
                        client->socket);
 
        rcu_read_lock();
@@ -3406,7 +3411,7 @@ int notification_thread_client_disconnect(
 
        ret = lttng_poll_del(&state->events, client->socket);
        if (ret) {
-               ERR("[notification-thread] Failed to remove client socket %d from poll set",
+               ERR("Failed to remove client socket %d from poll set",
                                client->socket);
        }
 
@@ -3432,12 +3437,12 @@ int handle_notification_thread_client_disconnect(
        struct notification_client *client;
 
        rcu_read_lock();
-       DBG("[notification-thread] Closing client connection (socket fd = %i)",
+       DBG("Closing client connection (socket fd = %i)",
                        client_socket);
        client = get_client_from_socket(client_socket, state);
        if (!client) {
                /* Internal state corruption, fatal error. */
-               ERR("[notification-thread] Unable to find client (socket fd = %i)",
+               ERR("Unable to find client (socket fd = %i)",
                                client_socket);
                ret = -1;
                goto end;
@@ -3457,7 +3462,7 @@ int handle_notification_thread_client_disconnect_all(
        bool error_encoutered = false;
 
        rcu_read_lock();
-       DBG("[notification-thread] Closing all client connections");
+       DBG("Closing all client connections");
        cds_lfht_for_each_entry(state->client_socket_ht, &iter, client,
                        client_socket_ht_node) {
                int ret;
@@ -3561,20 +3566,20 @@ enum client_transmission_status client_flush_outgoing_queue(
                 * If both data and fds are equal to zero, we are in an invalid
                 * state.
                 */
-               assert(fds_to_send_count != 0);
+               LTTNG_ASSERT(fds_to_send_count != 0);
                goto send_fds;
        }
 
        /* Send data. */
        to_send_count = pv.buffer.size;
-       DBG("[notification-thread] Flushing client (socket fd = %i) outgoing queue",
+       DBG("Flushing client (socket fd = %i) outgoing queue",
                        client->socket);
 
        ret = lttcomm_send_unix_sock_non_block(client->socket,
                        pv.buffer.data,
                        to_send_count);
        if ((ret >= 0 && ret < to_send_count)) {
-               DBG("[notification-thread] Client (socket fd = %i) outgoing queue could not be completely flushed",
+               DBG("Client (socket fd = %i) outgoing queue could not be completely flushed",
                                client->socket);
                to_send_count -= max(ret, 0);
 
@@ -3593,7 +3598,7 @@ enum client_transmission_status client_flush_outgoing_queue(
                goto end;
        } else if (ret < 0) {
                /* Generic error, disable the client's communication. */
-               ERR("[notification-thread] Failed to flush outgoing queue, disconnecting client (socket fd = %i)",
+               ERR("Failed to flush outgoing queue, disconnecting client (socket fd = %i)",
                                client->socket);
                client->communication.active = false;
                status = CLIENT_TRANSMISSION_STATUS_FAIL;
@@ -3625,7 +3630,7 @@ send_fds:
                        client->socket, &pv);
        if (ret < 0) {
                /* Generic error, disable the client's communication. */
-               ERR("[notification-thread] Failed to flush outgoing fds queue, disconnecting client (socket fd = %i)",
+               ERR("Failed to flush outgoing fds queue, disconnecting client (socket fd = %i)",
                                client->socket);
                client->communication.active = false;
                status = CLIENT_TRANSMISSION_STATUS_FAIL;
@@ -3690,7 +3695,7 @@ int client_send_command_reply(struct notification_client *client,
 
        memcpy(buffer, &msg, sizeof(msg));
        memcpy(buffer + sizeof(msg), &reply, sizeof(reply));
-       DBG("[notification-thread] Send command reply (%i)", (int) status);
+       DBG("Send command reply (%i)", (int) status);
 
        pthread_mutex_lock(&client->lock);
        if (client->communication.outbound.queued_command_reply) {
@@ -3739,13 +3744,13 @@ int client_handle_message_unknown(struct notification_client *client,
         */
        const struct lttng_notification_channel_message *msg;
 
-       assert(sizeof(*msg) == client->communication.inbound.payload.buffer.size);
+       LTTNG_ASSERT(sizeof(*msg) == client->communication.inbound.payload.buffer.size);
        msg = (const struct lttng_notification_channel_message *)
                              client->communication.inbound.payload.buffer.data;
 
        if (msg->size == 0 ||
                        msg->size > DEFAULT_MAX_NOTIFICATION_CLIENT_MESSAGE_PAYLOAD_SIZE) {
-               ERR("[notification-thread] Invalid notification channel message: length = %u",
+               ERR("Invalid notification channel message: length = %u",
                                msg->size);
                ret = -1;
                goto end;
@@ -3758,7 +3763,7 @@ int client_handle_message_unknown(struct notification_client *client,
                break;
        default:
                ret = -1;
-               ERR("[notification-thread] Invalid notification channel message: unexpected message type");
+               ERR("Invalid notification channel message: unexpected message type");
                goto end;
        }
 
@@ -3804,7 +3809,7 @@ int client_handle_message_handshake(struct notification_client *client,
        client->major = handshake_client->major;
        client->minor = handshake_client->minor;
        if (!client->communication.inbound.creds_received) {
-               ERR("[notification-thread] No credentials received from client");
+               ERR("No credentials received from client");
                ret = -1;
                goto end;
        }
@@ -3813,9 +3818,11 @@ int client_handle_message_handshake(struct notification_client *client,
                        &client->communication.inbound.creds);
        client->gid = LTTNG_SOCK_GET_GID_CRED(
                        &client->communication.inbound.creds);
-       DBG("[notification-thread] Received handshake from client (uid = %u, gid = %u) with version %i.%i",
+       client->is_sessiond = LTTNG_SOCK_GET_PID_CRED(&client->communication.inbound.creds) == getpid();
+       DBG("Received handshake from client: uid = %u, gid = %u, protocol version = %i.%i, client is sessiond = %s",
                        client->uid, client->gid, (int) client->major,
-                       (int) client->minor);
+                       (int) client->minor,
+                       client->is_sessiond ? "true" : "false");
 
        if (handshake_client->major !=
                        LTTNG_NOTIFICATION_CHANNEL_VERSION_MAJOR) {
@@ -3828,7 +3835,7 @@ int client_handle_message_handshake(struct notification_client *client,
                        &client->communication.outbound.payload.buffer, send_buffer,
                        sizeof(send_buffer));
        if (ret) {
-               ERR("[notification-thread] Failed to send protocol version to notification channel client");
+               ERR("Failed to send protocol version to notification channel client");
                goto end_unlock;
        }
 
@@ -3839,14 +3846,14 @@ int client_handle_message_handshake(struct notification_client *client,
        /* Set reception state to receive the next message header. */
        ret = client_reset_inbound_state(client);
        if (ret) {
-               ERR("[notification-thread] Failed to reset client communication's inbound state");
+               ERR("Failed to reset client communication's inbound state");
                goto end;
        }
 
        /* Flushes the outgoing queue. */
        ret = client_send_command_reply(client, state, status);
        if (ret) {
-               ERR("[notification-thread] Failed to send reply to notification channel client");
+               ERR("Failed to send reply to notification channel client");
                goto end;
        }
 
@@ -3881,10 +3888,11 @@ int client_handle_message_subscription(
        expected_condition_size = client->communication.inbound.payload.buffer.size;
        ret = lttng_condition_create_from_payload(&condition_view, &condition);
        if (ret != expected_condition_size) {
-               ERR("[notification-thread] Malformed condition received from client");
+               ERR("Malformed condition received from client");
                goto end;
        }
 
+       /* Ownership of condition is always transferred. */
        if (msg_type == LTTNG_NOTIFICATION_CHANNEL_MESSAGE_TYPE_SUBSCRIBE) {
                ret = notification_thread_client_subscribe(
                                client, condition, state, &status);
@@ -3900,13 +3908,13 @@ int client_handle_message_subscription(
        /* Set reception state to receive the next message header. */
        ret = client_reset_inbound_state(client);
        if (ret) {
-               ERR("[notification-thread] Failed to reset client communication's inbound state");
+               ERR("Failed to reset client communication's inbound state");
                goto end;
        }
 
        ret = client_send_command_reply(client, state, status);
        if (ret) {
-               ERR("[notification-thread] Failed to send reply to notification channel client");
+               ERR("Failed to send reply to notification channel client");
                goto end;
        }
 
@@ -3925,7 +3933,7 @@ int client_dispatch_message(struct notification_client *client,
                        client->communication.inbound.msg_type !=
                                LTTNG_NOTIFICATION_CHANNEL_MESSAGE_TYPE_UNKNOWN &&
                        !client->validated) {
-               WARN("[notification-thread] client attempted a command before handshake");
+               WARN("client attempted a command before handshake");
                ret = -1;
                goto end;
        }
@@ -3972,6 +3980,12 @@ int handle_notification_thread_client_in(
                goto end;
        }
 
+       if (client->communication.inbound.bytes_to_receive == 0 &&
+                       client->communication.inbound.fds_to_receive != 0) {
+               /* Only FDs left to receive. */
+               goto receive_fds;
+       }
+
        offset = client->communication.inbound.payload.buffer.size -
                        client->communication.inbound.bytes_to_receive;
        if (client->communication.inbound.expect_creds) {
@@ -4000,7 +4014,8 @@ int handle_notification_thread_client_in(
                goto end;
        }
 
-       assert(client->communication.inbound.bytes_to_receive == 0);
+receive_fds:
+       LTTNG_ASSERT(client->communication.inbound.bytes_to_receive == 0);
 
        /* Receive fds. */
        if (client->communication.inbound.fds_to_receive != 0) {
@@ -4018,7 +4033,7 @@ int handle_notification_thread_client_in(
                        expected_size = sizeof(int) *
                                        client->communication.inbound
                                                        .fds_to_receive;
-                       assert(ret == expected_size);
+                       LTTNG_ASSERT(ret == expected_size);
                        client->communication.inbound.fds_to_receive = 0;
                } else if (ret == 0) {
                        /* Received nothing. */
@@ -4030,7 +4045,7 @@ int handle_notification_thread_client_in(
        }
 
        /* At this point the message is complete.*/
-       assert(client->communication.inbound.bytes_to_receive == 0 &&
+       LTTNG_ASSERT(client->communication.inbound.bytes_to_receive == 0 &&
                        client->communication.inbound.fds_to_receive == 0);
        ret = client_dispatch_message(client, state);
        if (ret) {
@@ -4113,7 +4128,7 @@ bool evaluate_buffer_usage_condition(const struct lttng_condition *condition,
 
        condition_type = lttng_condition_get_type(condition);
        if (condition_type == LTTNG_CONDITION_TYPE_BUFFER_USAGE_LOW) {
-               DBG("[notification-thread] Low buffer usage condition being evaluated: threshold = %" PRIu64 ", highest usage = %" PRIu64,
+               DBG("Low buffer usage condition being evaluated: threshold = %" PRIu64 ", highest usage = %" PRIu64,
                                threshold, sample->highest_usage);
 
                /*
@@ -4124,7 +4139,7 @@ bool evaluate_buffer_usage_condition(const struct lttng_condition *condition,
                        result = true;
                }
        } else {
-               DBG("[notification-thread] High buffer usage condition being evaluated: threshold = %" PRIu64 ", highest usage = %" PRIu64,
+               DBG("High buffer usage condition being evaluated: threshold = %" PRIu64 ", highest usage = %" PRIu64,
                                threshold, sample->highest_usage);
 
                /*
@@ -4151,7 +4166,7 @@ bool evaluate_session_consumed_size_condition(
                                parent);
 
        threshold = size_condition->consumed_threshold_bytes.value;
-       DBG("[notification-thread] Session consumed size condition being evaluated: threshold = %" PRIu64 ", current size = %" PRIu64,
+       DBG("Session consumed size condition being evaluated: threshold = %" PRIu64 ", current size = %" PRIu64,
                        threshold, session_consumed_size);
        return session_consumed_size >= threshold;
 }
@@ -4335,7 +4350,6 @@ int send_evaluation_to_clients(const struct lttng_trigger *trigger,
  * interference from external users (those could, for instance, unregister
  * their triggers).
  */
-LTTNG_HIDDEN
 int notification_client_list_send_evaluation(
                struct notification_client_list *client_list,
                const struct lttng_trigger *trigger,
@@ -4367,7 +4381,7 @@ int notification_client_list_send_evaluation(
 
        ret = lttng_notification_serialize(&notification, &msg_payload);
        if (ret) {
-               ERR("[notification-thread] Failed to serialize notification");
+               ERR("Failed to serialize notification");
                ret = -1;
                goto end;
        }
@@ -4405,6 +4419,15 @@ int notification_client_list_send_evaluation(
                        goto skip_client;
                }
 
+               if (lttng_trigger_is_hidden(trigger) && !client->is_sessiond) {
+                       /*
+                        * Notifications resulting from an hidden trigger are
+                        * only sent to the session daemon.
+                        */
+                       DBG("Skipping client as the trigger is hidden and the client is not the session daemon");
+                       goto skip_client;
+               }
+
                if (source_object_creds) {
                        if (client->uid != lttng_credentials_get_uid(source_object_creds) &&
                                        client->gid != lttng_credentials_get_gid(source_object_creds) &&
@@ -4413,17 +4436,17 @@ int notification_client_list_send_evaluation(
                                 * Client is not allowed to monitor this
                                 * object.
                                 */
-                               DBG("[notification-thread] Skipping client at it does not have the object permission to receive notification for this trigger");
+                               DBG("Skipping client at it does not have the object permission to receive notification for this trigger");
                                goto skip_client;
                        }
                }
 
                if (client->uid != lttng_credentials_get_uid(trigger_creds)) {
-                       DBG("[notification-thread] Skipping client at it does not have the permission to receive notification for this trigger");
+                       DBG("Skipping client at it does not have the permission to receive notification for this trigger");
                        goto skip_client;
                }
 
-               DBG("[notification-thread] Sending notification to client (fd = %i, %zu bytes)",
+               DBG("Sending notification to client (fd = %i, %zu bytes)",
                                client->socket, msg_payload.buffer.size);
 
                if (client_has_outbound_data_left(client)) {
@@ -4486,7 +4509,7 @@ struct lttng_event_notifier_notification *recv_one_event_notifier_notification(
        size_t reception_size;
 
        struct lttng_ust_abi_event_notifier_notification ust_notification;
-       struct lttng_kernel_event_notifier_notification kernel_notification;
+       struct lttng_kernel_abi_event_notifier_notification kernel_notification;
 
        /* Init lttng_event_notifier_notification */
        switch(domain) {
@@ -4534,21 +4557,21 @@ struct lttng_event_notifier_notification *recv_one_event_notifier_notification(
        }
 
        if (capture_buffer_size > MAX_CAPTURE_SIZE) {
-               ERR("[notification-thread] Event notifier has a capture payload size which exceeds the maximum allowed size: capture_payload_size = %zu bytes, max allowed size = %d bytes",
+               ERR("Event notifier has a capture payload size which exceeds the maximum allowed size: capture_payload_size = %zu bytes, max allowed size = %d bytes",
                                capture_buffer_size, MAX_CAPTURE_SIZE);
                goto end;
        }
 
        capture_buffer = zmalloc(capture_buffer_size);
        if (!capture_buffer) {
-               ERR("[notification-thread] Failed to allocate capture buffer");
+               ERR("Failed to allocate capture buffer");
                goto end;
        }
 
        /* Fetch additional payload (capture). */
        ret = lttng_read(notification_pipe_read_fd, capture_buffer, capture_buffer_size);
        if (ret != capture_buffer_size) {
-               ERR("[notification-thread] Failed to read from event source pipe (fd = %i)",
+               ERR("Failed to read from event source pipe (fd = %i)",
                                notification_pipe_read_fd);
                goto end;
        }
@@ -4577,11 +4600,9 @@ int dispatch_one_event_notifier_notification(struct notification_thread_state *s
        struct cds_lfht_node *node;
        struct cds_lfht_iter iter;
        struct notification_trigger_tokens_ht_element *element;
-       enum lttng_trigger_status trigger_status;
        struct lttng_evaluation *evaluation = NULL;
        enum action_executor_status executor_status;
        struct notification_client_list *client_list = NULL;
-       const char *trigger_name;
        int ret;
        unsigned int capture_count = 0;
 
@@ -4606,10 +4627,7 @@ int dispatch_one_event_notifier_notification(struct notification_thread_state *s
                        struct notification_trigger_tokens_ht_element,
                        node);
 
-       trigger_status = lttng_trigger_get_name(element->trigger, &trigger_name);
-       assert(trigger_status == LTTNG_TRIGGER_STATUS_OK);
-
-       if (lttng_condition_on_event_get_capture_descriptor_count(
+       if (lttng_condition_event_rule_matches_get_capture_descriptor_count(
                            lttng_trigger_get_const_condition(element->trigger),
                            &capture_count) != LTTNG_CONDITION_STATUS_OK) {
                ERR("Failed to get capture count");
@@ -4623,19 +4641,20 @@ int dispatch_one_event_notifier_notification(struct notification_thread_state *s
                goto end;
        }
 
-       evaluation = lttng_evaluation_on_event_create(
+       evaluation = lttng_evaluation_event_rule_matches_create(
                        container_of(lttng_trigger_get_const_condition(
                                                     element->trigger),
-                                       struct lttng_condition_on_event,
+                                       struct lttng_condition_event_rule_matches,
                                        parent),
                        notification->capture_buffer,
                        notification->capture_buf_size, false);
 
        if (evaluation == NULL) {
-               ERR("[notification-thread] Failed to create event rule hit evaluation while creating and enqueuing action executor job");
+               ERR("Failed to create event rule matches evaluation while creating and enqueuing action executor job");
                ret = -1;
                goto end_unlock;
        }
+
        client_list = get_client_list_from_condition(state,
                        lttng_trigger_get_const_condition(element->trigger));
        executor_status = action_executor_enqueue_trigger(state->executor,
@@ -4722,14 +4741,14 @@ int handle_one_event_notifier_notification(
        notification = recv_one_event_notifier_notification(pipe, domain);
        if (notification == NULL) {
                /* Reception failed, don't consider it fatal. */
-               ERR("[notification-thread] Error receiving an event notifier notification from tracer: fd = %i, domain = %s",
+               ERR("Error receiving an event notifier notification from tracer: fd = %i, domain = %s",
                                pipe, lttng_domain_type_str(domain));
                goto end;
        }
 
        ret = dispatch_one_event_notifier_notification(state, notification);
        if (ret) {
-               ERR("[notification-thread] Error dispatching an event notifier notification from tracer: fd = %i, domain = %s",
+               ERR("Error dispatching an event notifier notification from tracer: fd = %i, domain = %s",
                                pipe, lttng_domain_type_str(domain));
                goto end;
        }
@@ -4767,7 +4786,7 @@ int handle_notification_thread_channel_sample(
         */
        ret = lttng_read(pipe, &sample_msg, sizeof(sample_msg));
        if (ret != sizeof(sample_msg)) {
-               ERR("[notification-thread] Failed to read from monitoring pipe (fd = %i)",
+               ERR("Failed to read from monitoring pipe (fd = %i)",
                                pipe);
                ret = -1;
                goto end;
@@ -4796,14 +4815,14 @@ int handle_notification_thread_channel_sample(
                 * channel's destruction before we get a chance to process that
                 * sample.
                 */
-               DBG("[notification-thread] Received a sample for an unknown channel from consumerd, key = %" PRIu64 " in %s domain",
+               DBG("Received a sample for an unknown channel from consumerd, key = %" PRIu64 " in %s domain",
                                latest_sample.key.key,
                                lttng_domain_type_str(domain));
                goto end_unlock;
        }
        channel_info = caa_container_of(node, struct channel_info,
                        channels_ht_node);
-       DBG("[notification-thread] Handling channel sample for channel %s (key = %" PRIu64 ") in session %s (highest usage = %" PRIu64 ", lowest usage = %" PRIu64", total consumed = %" PRIu64")",
+       DBG("Handling channel sample for channel %s (key = %" PRIu64 ") in session %s (highest usage = %" PRIu64 ", lowest usage = %" PRIu64", total consumed = %" PRIu64")",
                        channel_info->name,
                        latest_sample.key.key,
                        channel_info->session_info->name,
@@ -4895,7 +4914,7 @@ int handle_notification_thread_channel_sample(
                ret = 0;
                trigger = trigger_list_element->trigger;
                condition = lttng_trigger_get_const_condition(trigger);
-               assert(condition);
+               LTTNG_ASSERT(condition);
 
                /*
                 * Check if any client is subscribed to the result of this
This page took 0.050193 seconds and 4 git commands to generate.