Clean-up: modernize pretty_xml.cpp
[lttng-tools.git] / src / bin / lttng-sessiond / notification-thread-events.cpp
index 8c009f748cc39f28129759ff46a1fc2bccfb2303..8065cd7323b20f8c9ca8bfa137d88ff44d9c5810 100644 (file)
 #include <common/futex.hpp>
 #include <common/hashtable/utils.hpp>
 #include <common/macros.hpp>
+#include <common/pthread-lock.hpp>
 #include <common/sessiond-comm/sessiond-comm.hpp>
 #include <common/unix.hpp>
+#include <common/urcu.hpp>
 
 #include <lttng/action/action-internal.hpp>
 #include <lttng/action/list-internal.hpp>
@@ -324,7 +326,7 @@ static struct session_info *get_session_info_by_id(const struct notification_thr
                return session_info;
        }
 
-       return NULL;
+       return nullptr;
 }
 
 static struct session_info *get_session_info_by_name(const struct notification_thread_state *state,
@@ -333,7 +335,7 @@ static struct session_info *get_session_info_by_name(const struct notification_t
        uint64_t session_id;
        const auto found = sample_session_id_by_name(name, &session_id);
 
-       return found ? get_session_info_by_id(state, session_id) : NULL;
+       return found ? get_session_info_by_id(state, session_id) : nullptr;
 }
 
 static const char *notification_command_type_str(enum notification_thread_command_type type)
@@ -389,10 +391,10 @@ static int match_trigger_by_name_uid(struct cds_lfht_node *node, const void *key
                caa_container_of(node, struct lttng_trigger_ht_element, node_by_name_uid);
 
        status = lttng_trigger_get_name(trigger_ht_element->trigger, &element_trigger_name);
-       element_trigger_name = status == LTTNG_TRIGGER_STATUS_OK ? element_trigger_name : NULL;
+       element_trigger_name = status == LTTNG_TRIGGER_STATUS_OK ? element_trigger_name : nullptr;
 
        status = lttng_trigger_get_name(trigger_key, &key_name);
-       key_name = status == LTTNG_TRIGGER_STATUS_OK ? key_name : NULL;
+       key_name = status == LTTNG_TRIGGER_STATUS_OK ? key_name : nullptr;
 
        /*
         * Compare the names.
@@ -518,16 +520,15 @@ static void session_info_destroy(void *_data)
 
        LTTNG_ASSERT(session_info);
        if (session_info->channel_infos_ht) {
-               ret = cds_lfht_destroy(session_info->channel_infos_ht, NULL);
+               ret = cds_lfht_destroy(session_info->channel_infos_ht, nullptr);
                if (ret) {
                        ERR("Failed to destroy channel information hash table");
                }
        }
        lttng_session_trigger_list_destroy(session_info->trigger_list);
 
-       rcu_read_lock();
+       lttng::urcu::read_lock_guard read_lock;
        cds_lfht_del(session_info->sessions_ht, &session_info->sessions_ht_node);
-       rcu_read_unlock();
        free(session_info->name);
        lttng_trace_archive_location_put(session_info->last_state_sample.rotation.location);
        call_rcu(&session_info->rcu_node, free_session_info_rcu);
@@ -568,7 +569,7 @@ static struct session_info *session_info_create(uint64_t id,
        lttng_ref_init(&session_info->ref, session_info_destroy);
 
        session_info->channel_infos_ht = cds_lfht_new(
-               DEFAULT_HT_SIZE, 1, 0, CDS_LFHT_AUTO_RESIZE | CDS_LFHT_ACCOUNTING, NULL);
+               DEFAULT_HT_SIZE, 1, 0, CDS_LFHT_AUTO_RESIZE | CDS_LFHT_ACCOUNTING, nullptr);
        if (!session_info->channel_infos_ht) {
                goto error;
        }
@@ -588,25 +589,23 @@ end:
        return session_info;
 error:
        session_info_put(session_info);
-       return NULL;
+       return nullptr;
 }
 
 static void session_info_add_channel(struct session_info *session_info,
                                     struct channel_info *channel_info)
 {
-       rcu_read_lock();
+       lttng::urcu::read_lock_guard read_lock;
        cds_lfht_add(session_info->channel_infos_ht,
                     hash_channel_key(&channel_info->key),
                     &channel_info->session_info_channels_ht_node);
-       rcu_read_unlock();
 }
 
 static void session_info_remove_channel(struct session_info *session_info,
                                        struct channel_info *channel_info)
 {
-       rcu_read_lock();
+       lttng::urcu::read_lock_guard read_lock;
        cds_lfht_del(session_info->channel_infos_ht, &channel_info->session_info_channels_ht_node);
-       rcu_read_unlock();
 }
 
 static struct channel_info *channel_info_create(const char *channel_name,
@@ -642,7 +641,7 @@ end:
        return channel_info;
 error:
        channel_info_destroy(channel_info);
-       return NULL;
+       return nullptr;
 }
 
 bool notification_client_list_get(struct notification_client_list *list)
@@ -664,12 +663,11 @@ static void notification_client_list_release(struct urcu_ref *list_ref)
        lttng_condition_put(list->condition);
 
        if (list->notification_trigger_clients_ht) {
-               rcu_read_lock();
+               lttng::urcu::read_lock_guard read_lock;
 
                cds_lfht_del(list->notification_trigger_clients_ht,
                             &list->notification_trigger_clients_ht_node);
-               rcu_read_unlock();
-               list->notification_trigger_clients_ht = NULL;
+               list->notification_trigger_clients_ht = nullptr;
        }
        cds_list_for_each_entry_safe (client_list_element, tmp, &list->clients_list, node) {
                free(client_list_element);
@@ -711,7 +709,7 @@ notification_client_list_create(struct notification_thread_state *state,
                goto end;
        }
 
-       pthread_mutex_init(&client_list->lock, NULL);
+       pthread_mutex_init(&client_list->lock, nullptr);
        /*
         * The trigger that owns the condition has the first reference to this
         * client list.
@@ -728,41 +726,48 @@ notification_client_list_create(struct notification_thread_state *state,
         */
        client_list->condition = lttng_condition_copy(condition);
 
-       /* Build a list of clients to which this new condition applies. */
-       cds_lfht_for_each_entry (state->client_socket_ht, &iter, client, client_socket_ht_node) {
-               struct notification_client_list_element *client_list_element;
+       {
+               /* Build a list of clients to which this new condition applies. */
+               lttng::urcu::read_lock_guard read_lock;
 
-               if (!condition_applies_to_client(condition, client)) {
-                       continue;
-               }
+               cds_lfht_for_each_entry (
+                       state->client_socket_ht, &iter, client, client_socket_ht_node) {
+                       struct notification_client_list_element *client_list_element;
 
-               client_list_element = zmalloc<notification_client_list_element>();
-               if (!client_list_element) {
-                       goto error_put_client_list;
-               }
+                       if (!condition_applies_to_client(condition, client)) {
+                               continue;
+                       }
+
+                       client_list_element = zmalloc<notification_client_list_element>();
+                       if (!client_list_element) {
+                               goto error_put_client_list;
+                       }
 
-               CDS_INIT_LIST_HEAD(&client_list_element->node);
-               client_list_element->client = client;
-               cds_list_add(&client_list_element->node, &client_list->clients_list);
+                       CDS_INIT_LIST_HEAD(&client_list_element->node);
+                       client_list_element->client = client;
+                       cds_list_add(&client_list_element->node, &client_list->clients_list);
+               }
        }
 
        client_list->notification_trigger_clients_ht = state->notification_trigger_clients_ht;
 
-       rcu_read_lock();
        /*
         * Add the client list to the global list of client list.
         */
-       cds_lfht_add_unique(state->notification_trigger_clients_ht,
-                           lttng_condition_hash(client_list->condition),
-                           match_client_list_condition,
-                           client_list->condition,
-                           &client_list->notification_trigger_clients_ht_node);
-       rcu_read_unlock();
+       {
+               lttng::urcu::read_lock_guard read_lock;
+
+               cds_lfht_add_unique(state->notification_trigger_clients_ht,
+                                   lttng_condition_hash(client_list->condition),
+                                   match_client_list_condition,
+                                   client_list->condition,
+                                   &client_list->notification_trigger_clients_ht_node);
+       }
        goto end;
 
 error_put_client_list:
        notification_client_list_put(client_list);
-       client_list = NULL;
+       client_list = nullptr;
 
 end:
        return client_list;
@@ -783,9 +788,9 @@ get_client_list_from_condition(struct notification_thread_state *state,
 {
        struct cds_lfht_node *node;
        struct cds_lfht_iter iter;
-       struct notification_client_list *list = NULL;
+       struct notification_client_list *list = nullptr;
 
-       rcu_read_lock();
+       lttng::urcu::read_lock_guard read_lock;
        cds_lfht_lookup(state->notification_trigger_clients_ht,
                        lttng_condition_hash(condition),
                        match_client_list_condition,
@@ -795,10 +800,9 @@ get_client_list_from_condition(struct notification_thread_state *state,
        if (node) {
                list = lttng::utils::container_of(
                        node, &notification_client_list::notification_trigger_clients_ht_node);
-               list = notification_client_list_get(list) ? list : NULL;
+               list = notification_client_list_get(list) ? list : nullptr;
        }
 
-       rcu_read_unlock();
        return list;
 }
 
@@ -811,12 +815,12 @@ static int evaluate_channel_condition_for_client(const struct lttng_condition *c
        int ret;
        struct cds_lfht_iter iter;
        struct cds_lfht_node *node;
-       struct channel_info *channel_info = NULL;
-       struct channel_key *channel_key = NULL;
-       struct channel_state_sample *last_sample = NULL;
-       struct lttng_channel_trigger_list *channel_trigger_list = NULL;
+       struct channel_info *channel_info = nullptr;
+       struct channel_key *channel_key = nullptr;
+       struct channel_state_sample *last_sample = nullptr;
+       struct lttng_channel_trigger_list *channel_trigger_list = nullptr;
 
-       rcu_read_lock();
+       lttng::urcu::read_lock_guard read_lock;
 
        /* Find the channel associated with the condition. */
        cds_lfht_for_each_entry (
@@ -877,7 +881,7 @@ static int evaluate_channel_condition_for_client(const struct lttng_condition *c
        }
 
        ret = evaluate_buffer_condition(
-               condition, evaluation, state, NULL, last_sample, channel_info);
+               condition, evaluation, state, nullptr, last_sample, channel_info);
        if (ret) {
                WARN("Fatal error occurred while evaluating a newly subscribed-to condition");
                goto end;
@@ -886,13 +890,12 @@ static int evaluate_channel_condition_for_client(const struct lttng_condition *c
        *session_uid = channel_info->session_info->uid;
        *session_gid = channel_info->session_info->gid;
 end:
-       rcu_read_unlock();
        return ret;
 }
 
 static const char *get_condition_session_name(const struct lttng_condition *condition)
 {
-       const char *session_name = NULL;
+       const char *session_name = nullptr;
        enum lttng_condition_status status;
 
        switch (lttng_condition_get_type(condition)) {
@@ -1060,14 +1063,14 @@ static int evaluate_condition_for_client(const struct lttng_trigger *trigger,
                                         struct notification_thread_state *state)
 {
        int ret;
-       struct lttng_evaluation *evaluation = NULL;
+       struct lttng_evaluation *evaluation = nullptr;
        struct notification_client_list client_list = {
                .lock = PTHREAD_MUTEX_INITIALIZER,
                .ref = {},
-               .condition = NULL,
+               .condition = nullptr,
                .triggers_list = {},
                .clients_list = {},
-               .notification_trigger_clients_ht = NULL,
+               .notification_trigger_clients_ht = nullptr,
                .notification_trigger_clients_ht_node = {},
                .rcu_node = {},
        };
@@ -1097,7 +1100,7 @@ static int evaluate_condition_for_client(const struct lttng_trigger *trigger,
                object_uid = session_info->uid;
                object_gid = session_info->gid;
 
-               ret = evaluate_session_condition(condition, session_info, NULL, &evaluation);
+               ret = evaluate_session_condition(condition, session_info, nullptr, &evaluation);
                session_info_put(session_info);
                break;
        }
@@ -1151,9 +1154,9 @@ static int notification_thread_client_subscribe(struct notification_client *clie
                                                enum lttng_notification_channel_status *_status)
 {
        int ret = 0;
-       struct notification_client_list *client_list = NULL;
-       struct lttng_condition_list_element *condition_list_element = NULL;
-       struct notification_client_list_element *client_list_element = NULL;
+       struct notification_client_list *client_list = nullptr;
+       struct lttng_condition_list_element *condition_list_element = nullptr;
+       struct notification_client_list_element *client_list_element = nullptr;
        struct lttng_trigger_ht_element *trigger_ht_element;
        enum lttng_notification_channel_status status = LTTNG_NOTIFICATION_CHANNEL_STATUS_OK;
 
@@ -1184,7 +1187,7 @@ static int notification_thread_client_subscribe(struct notification_client *clie
         */
        CDS_INIT_LIST_HEAD(&condition_list_element->node);
        condition_list_element->condition = condition;
-       condition = NULL;
+       condition = nullptr;
        cds_list_add(&condition_list_element->node, &client->condition_list);
 
        client_list = get_client_list_from_condition(state, condition_list_element->condition);
@@ -1309,7 +1312,7 @@ static int notification_thread_client_unsubscribe(struct notification_client *cl
        }
        pthread_mutex_unlock(&client_list->lock);
        notification_client_list_put(client_list);
-       client_list = NULL;
+       client_list = nullptr;
 end:
        lttng_condition_destroy(condition);
        if (_status) {
@@ -1353,7 +1356,7 @@ static struct notification_client *get_client_from_socket(int socket,
 {
        struct cds_lfht_iter iter;
        struct cds_lfht_node *node;
-       struct notification_client *client = NULL;
+       struct notification_client *client = nullptr;
 
        ASSERT_RCU_READ_LOCKED();
 
@@ -1381,7 +1384,7 @@ static struct notification_client *get_client_from_id(notification_client_id id,
 {
        struct cds_lfht_iter iter;
        struct cds_lfht_node *node;
-       struct notification_client *client = NULL;
+       struct notification_client *client = nullptr;
 
        ASSERT_RCU_READ_LOCKED();
 
@@ -1401,8 +1404,8 @@ static bool buffer_usage_condition_applies_to_channel(const struct lttng_conditi
 {
        enum lttng_condition_status status;
        enum lttng_domain_type condition_domain;
-       const char *condition_session_name = NULL;
-       const char *condition_channel_name = NULL;
+       const char *condition_session_name = nullptr;
+       const char *condition_channel_name = nullptr;
 
        status = lttng_condition_buffer_usage_get_domain_type(condition, &condition_domain);
        LTTNG_ASSERT(status == LTTNG_CONDITION_STATUS_OK);
@@ -1416,10 +1419,10 @@ static bool buffer_usage_condition_applies_to_channel(const struct lttng_conditi
        status = lttng_condition_buffer_usage_get_channel_name(condition, &condition_channel_name);
        LTTNG_ASSERT((status == LTTNG_CONDITION_STATUS_OK) && condition_channel_name);
 
-       if (strcmp(channel_info->session_info->name, condition_session_name)) {
+       if (strcmp(channel_info->session_info->name, condition_session_name) != 0) {
                goto fail;
        }
-       if (strcmp(channel_info->name, condition_channel_name)) {
+       if (strcmp(channel_info->name, condition_channel_name) != 0) {
                goto fail;
        }
 
@@ -1458,7 +1461,7 @@ fail:
 static struct lttng_session_trigger_list *
 get_session_trigger_list(struct notification_thread_state *state, const char *session_name)
 {
-       struct lttng_session_trigger_list *list = NULL;
+       struct lttng_session_trigger_list *list = nullptr;
        struct cds_lfht_node *node;
        struct cds_lfht_iter iter;
 
@@ -1492,7 +1495,7 @@ end:
 static struct lttng_session_trigger_list *
 lttng_session_trigger_list_create(const char *session_name, struct cds_lfht *session_triggers_ht)
 {
-       struct lttng_session_trigger_list *list = NULL;
+       struct lttng_session_trigger_list *list = nullptr;
        char *session_name_copy = strdup(session_name);
 
        if (!session_name_copy) {
@@ -1511,12 +1514,13 @@ lttng_session_trigger_list_create(const char *session_name, struct cds_lfht *ses
        cds_lfht_node_init(&list->session_triggers_ht_node);
        list->session_triggers_ht = session_triggers_ht;
 
-       rcu_read_lock();
        /* Publish the list through the session_triggers_ht. */
-       cds_lfht_add(session_triggers_ht,
-                    hash_key_str(session_name, lttng_ht_seed),
-                    &list->session_triggers_ht_node);
-       rcu_read_unlock();
+       {
+               lttng::urcu::read_lock_guard read_lock;
+               cds_lfht_add(session_triggers_ht,
+                            hash_key_str(session_name, lttng_ht_seed),
+                            &list->session_triggers_ht_node);
+       }
 end:
        return list;
 }
@@ -1539,10 +1543,9 @@ static void lttng_session_trigger_list_destroy(struct lttng_session_trigger_list
                cds_list_del(&trigger_list_element->node);
                free(trigger_list_element);
        }
-       rcu_read_lock();
+       lttng::urcu::read_lock_guard read_lock;
        /* Unpublish the list from the session_triggers_ht. */
        cds_lfht_del(list->session_triggers_ht, &list->session_triggers_ht_node);
-       rcu_read_unlock();
        call_rcu(&list->rcu_node, free_session_trigger_list_rcu);
 }
 
@@ -1598,35 +1601,40 @@ lttng_session_trigger_list_build(const struct notification_thread_state *state,
                                 const char *session_name)
 {
        int trigger_count = 0;
-       struct lttng_session_trigger_list *session_trigger_list = NULL;
-       struct lttng_trigger_ht_element *trigger_ht_element = NULL;
+       struct lttng_session_trigger_list *session_trigger_list = nullptr;
+       struct lttng_trigger_ht_element *trigger_ht_element = nullptr;
        struct cds_lfht_iter iter;
 
        session_trigger_list =
                lttng_session_trigger_list_create(session_name, state->session_triggers_ht);
 
-       /* Add all triggers applying to the session named 'session_name'. */
-       cds_lfht_for_each_entry (state->triggers_ht, &iter, trigger_ht_element, node) {
-               int ret;
+       {
+               /* Add all triggers applying to the session named 'session_name'. */
+               lttng::urcu::read_lock_guard read_lock;
 
-               if (!trigger_applies_to_session(trigger_ht_element->trigger, session_name)) {
-                       continue;
-               }
+               cds_lfht_for_each_entry (state->triggers_ht, &iter, trigger_ht_element, node) {
+                       int ret;
 
-               ret = lttng_session_trigger_list_add(session_trigger_list,
-                                                    trigger_ht_element->trigger);
-               if (ret) {
-                       goto error;
-               }
+                       if (!trigger_applies_to_session(trigger_ht_element->trigger,
+                                                       session_name)) {
+                               continue;
+                       }
 
-               trigger_count++;
+                       ret = lttng_session_trigger_list_add(session_trigger_list,
+                                                            trigger_ht_element->trigger);
+                       if (ret) {
+                               goto error;
+                       }
+
+                       trigger_count++;
+               }
        }
 
        DBG("Found %i triggers that apply to newly created session", trigger_count);
        return session_trigger_list;
 error:
        lttng_session_trigger_list_destroy(session_trigger_list);
-       return NULL;
+       return nullptr;
 }
 
 static struct session_info *create_and_publish_session_info(struct notification_thread_state *state,
@@ -1635,10 +1643,10 @@ static struct session_info *create_and_publish_session_info(struct notification_
                                                            uid_t uid,
                                                            gid_t gid)
 {
-       struct session_info *session = NULL;
+       struct session_info *session = nullptr;
        struct lttng_session_trigger_list *trigger_list;
 
-       rcu_read_lock();
+       lttng::urcu::read_lock_guard read_lock;
        trigger_list = lttng_session_trigger_list_build(state, name);
        if (!trigger_list) {
                goto error;
@@ -1655,7 +1663,7 @@ static struct session_info *create_and_publish_session_info(struct notification_
        }
 
        /* Transferred ownership to the new session. */
-       trigger_list = NULL;
+       trigger_list = nullptr;
 
        if (cds_lfht_add_unique(state->sessions_ht,
                                hash_session_info(session),
@@ -1666,12 +1674,10 @@ static struct session_info *create_and_publish_session_info(struct notification_
                goto error;
        }
 
-       rcu_read_unlock();
        return session;
 error:
-       rcu_read_unlock();
        session_info_put(session);
-       return NULL;
+       return nullptr;
 }
 
 static int handle_notification_thread_command_add_channel(struct notification_thread_state *state,
@@ -1683,16 +1689,17 @@ static int handle_notification_thread_command_add_channel(struct notification_th
                                                          enum lttng_error_code *cmd_result)
 {
        struct cds_list_head trigger_list;
-       struct channel_info *new_channel_info = NULL;
+       struct channel_info *new_channel_info = nullptr;
        struct channel_key channel_key = {
                .key = channel_key_int,
                .domain = channel_domain,
        };
-       struct lttng_channel_trigger_list *channel_trigger_list = NULL;
-       struct lttng_trigger_ht_element *trigger_ht_element = NULL;
+       struct lttng_channel_trigger_list *channel_trigger_list = nullptr;
+       struct lttng_trigger_ht_element *trigger_ht_element = nullptr;
        int trigger_count = 0;
        struct cds_lfht_iter iter;
-       struct session_info *session_info = NULL;
+       struct session_info *session_info = nullptr;
+       lttng::urcu::read_lock_guard read_lock;
 
        DBG("Adding channel: channel name = `%s`, session id = %" PRIu64 ", channel key = %" PRIu64
            ", domain = %s",
@@ -1717,7 +1724,6 @@ static int handle_notification_thread_command_add_channel(struct notification_th
                goto error;
        }
 
-       rcu_read_lock();
        /* Build a list of all triggers applying to the new channel. */
        cds_lfht_for_each_entry (state->triggers_ht, &iter, trigger_ht_element, node) {
                struct lttng_trigger_list_element *new_element;
@@ -1728,7 +1734,6 @@ static int handle_notification_thread_command_add_channel(struct notification_th
 
                new_element = zmalloc<lttng_trigger_list_element>();
                if (!new_element) {
-                       rcu_read_unlock();
                        goto error;
                }
                CDS_INIT_LIST_HEAD(&new_element->node);
@@ -1736,7 +1741,6 @@ static int handle_notification_thread_command_add_channel(struct notification_th
                cds_list_add(&new_element->node, &trigger_list);
                trigger_count++;
        }
-       rcu_read_unlock();
 
        DBG("Found %i triggers that apply to newly added channel", trigger_count);
        channel_trigger_list = zmalloc<lttng_channel_trigger_list>();
@@ -1748,7 +1752,6 @@ static int handle_notification_thread_command_add_channel(struct notification_th
        cds_lfht_node_init(&channel_trigger_list->channel_triggers_ht_node);
        cds_list_splice(&trigger_list, &channel_trigger_list->list);
 
-       rcu_read_lock();
        /* Add channel to the channel_ht which owns the channel_infos. */
        cds_lfht_add(state->channels_ht,
                     hash_channel_key(&new_channel_info->key),
@@ -1760,7 +1763,6 @@ static int handle_notification_thread_command_add_channel(struct notification_th
        cds_lfht_add(state->channel_triggers_ht,
                     hash_channel_key(&new_channel_info->key),
                     &channel_trigger_list->channel_triggers_ht_node);
-       rcu_read_unlock();
        session_info_put(session_info);
        *cmd_result = LTTNG_OK;
        return 0;
@@ -1865,7 +1867,7 @@ handle_notification_thread_command_remove_channel(struct notification_thread_sta
            channel_key,
            lttng_domain_type_str(domain));
 
-       rcu_read_lock();
+       lttng::urcu::read_lock_guard read_lock;
 
        cds_lfht_lookup(state->channel_triggers_ht,
                        hash_channel_key(&key),
@@ -1920,7 +1922,6 @@ handle_notification_thread_command_remove_channel(struct notification_thread_sta
        cds_lfht_del(state->channels_ht, node);
        channel_info_destroy(channel_info);
 end:
-       rcu_read_unlock();
        *cmd_result = LTTNG_OK;
        return 0;
 }
@@ -1941,7 +1942,7 @@ handle_notification_thread_command_session_rotation(struct notification_thread_s
        struct lttng_credentials session_creds;
        struct session_state_sample new_session_state;
 
-       rcu_read_lock();
+       lttng::urcu::read_lock_guard read_lock;
 
        session_info = get_session_info_by_id(state, session_id);
        if (!session_info) {
@@ -1958,7 +1959,7 @@ handle_notification_thread_command_session_rotation(struct notification_thread_s
                lttng_trace_archive_location_get(location);
                new_session_state.rotation.location = location;
        } else {
-               new_session_state.rotation.location = NULL;
+               new_session_state.rotation.location = nullptr;
        }
 
        session_creds = {
@@ -1977,7 +1978,7 @@ handle_notification_thread_command_session_rotation(struct notification_thread_s
                const struct lttng_condition *condition;
                struct lttng_trigger *trigger;
                struct notification_client_list *client_list;
-               struct lttng_evaluation *evaluation = NULL;
+               struct lttng_evaluation *evaluation = nullptr;
                enum action_executor_status executor_status;
 
                trigger = trigger_list_element->trigger;
@@ -2005,7 +2006,7 @@ handle_notification_thread_command_session_rotation(struct notification_thread_s
                executor_status = action_executor_enqueue_trigger(
                        state->executor, trigger, evaluation, &session_creds, client_list);
                notification_client_list_put(client_list);
-               evaluation = NULL;
+               evaluation = nullptr;
                switch (executor_status) {
                case ACTION_EXECUTOR_STATUS_OK:
                        break;
@@ -2042,7 +2043,6 @@ end:
 
        session_info_put(session_info);
        *_cmd_result = cmd_result;
-       rcu_read_unlock();
        return ret;
 }
 
@@ -2054,7 +2054,7 @@ handle_notification_thread_command_add_tracer_event_source(struct notification_t
 {
        int ret = 0;
        enum lttng_error_code cmd_result = LTTNG_OK;
-       struct notification_event_tracer_event_source_element *element = NULL;
+       struct notification_event_tracer_event_source_element *element = nullptr;
 
        element = zmalloc<notification_event_tracer_event_source_element>();
        if (!element) {
@@ -2154,7 +2154,7 @@ find_tracer_event_source_element(struct notification_thread_state *state,
                }
        }
 
-       source_element = NULL;
+       source_element = nullptr;
 end:
        return source_element;
 }
@@ -2228,7 +2228,7 @@ static int handle_notification_thread_command_remove_tracer_event_source(
 {
        int ret = 0;
        enum lttng_error_code cmd_result = LTTNG_OK;
-       struct notification_event_tracer_event_source_element *source_element = NULL;
+       struct notification_event_tracer_event_source_element *source_element = nullptr;
 
        source_element = find_tracer_event_source_element(state, tracer_event_source_fd);
 
@@ -2266,10 +2266,10 @@ handle_notification_thread_command_list_triggers(struct notification_thread_hand
        enum lttng_error_code cmd_result = LTTNG_OK;
        struct cds_lfht_iter iter;
        struct lttng_trigger_ht_element *trigger_ht_element;
-       struct lttng_triggers *local_triggers = NULL;
+       struct lttng_triggers *local_triggers = nullptr;
        const struct lttng_credentials *creds;
 
-       rcu_read_lock();
+       lttng::urcu::read_lock_guard read_lock;
 
        local_triggers = lttng_triggers_create();
        if (!local_triggers) {
@@ -2299,10 +2299,9 @@ handle_notification_thread_command_list_triggers(struct notification_thread_hand
 
        /* Transferring ownership to the caller. */
        *triggers = local_triggers;
-       local_triggers = NULL;
+       local_triggers = nullptr;
 
 end:
-       rcu_read_unlock();
        lttng_triggers_destroy(local_triggers);
        *_cmd_result = cmd_result;
        return ret;
@@ -2341,16 +2340,18 @@ static int handle_notification_thread_command_get_trigger(struct notification_th
        const char *trigger_name;
        uid_t trigger_owner_uid;
 
-       rcu_read_lock();
+       {
+               lttng::urcu::read_lock_guard read_lock;
 
-       cds_lfht_for_each_entry (state->triggers_ht, &iter, trigger_ht_element, node) {
-               if (lttng_trigger_is_equal(trigger, trigger_ht_element->trigger)) {
-                       /* Take one reference on the return trigger. */
-                       *registered_trigger = trigger_ht_element->trigger;
-                       lttng_trigger_get(*registered_trigger);
-                       ret = 0;
-                       cmd_result = LTTNG_OK;
-                       goto end;
+               cds_lfht_for_each_entry (state->triggers_ht, &iter, trigger_ht_element, node) {
+                       if (lttng_trigger_is_equal(trigger, trigger_ht_element->trigger)) {
+                               /* Take one reference on the return trigger. */
+                               *registered_trigger = trigger_ht_element->trigger;
+                               lttng_trigger_get(*registered_trigger);
+                               ret = 0;
+                               cmd_result = LTTNG_OK;
+                               goto end;
+                       }
                }
        }
 
@@ -2363,7 +2364,6 @@ static int handle_notification_thread_command_get_trigger(struct notification_th
        ret = 0;
 
 end:
-       rcu_read_unlock();
        *_cmd_result = cmd_result;
        return ret;
 }
@@ -2503,8 +2503,6 @@ end:
 static bool is_trigger_action_notify(const struct lttng_trigger *trigger)
 {
        bool is_notify = false;
-       unsigned int i, count;
-       enum lttng_action_status action_status;
        const struct lttng_action *action = lttng_trigger_get_const_action(trigger);
        enum lttng_action_type action_type;
 
@@ -2517,14 +2515,8 @@ static bool is_trigger_action_notify(const struct lttng_trigger *trigger)
                goto end;
        }
 
-       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_list_get_at_index(action, i);
-
-               action_type = lttng_action_get_type(inner_action);
-               if (action_type == LTTNG_ACTION_TYPE_NOTIFY) {
+       for (auto inner_action : lttng::ctl::const_action_list_view(action)) {
+               if (lttng_action_get_type(inner_action) == LTTNG_ACTION_TYPE_NOTIFY) {
                        is_notify = true;
                        goto end;
                }
@@ -2596,7 +2588,7 @@ static enum lttng_error_code setup_tracer_notifier(struct notification_thread_st
        struct cds_lfht_node *node;
        uint64_t error_counter_index = 0;
        struct lttng_condition *condition = lttng_trigger_get_condition(trigger);
-       struct notification_trigger_tokens_ht_element *trigger_tokens_ht_element = NULL;
+       struct notification_trigger_tokens_ht_element *trigger_tokens_ht_element = nullptr;
 
        trigger_tokens_ht_element = zmalloc<notification_trigger_tokens_ht_element>();
        if (!trigger_tokens_ht_element) {
@@ -2670,19 +2662,19 @@ handle_notification_thread_command_register_trigger(struct notification_thread_s
 {
        int ret = 0;
        struct lttng_condition *condition;
-       struct notification_client_list *client_list = NULL;
-       struct lttng_trigger_ht_element *trigger_ht_element = NULL;
+       struct notification_client_list *client_list = nullptr;
+       struct lttng_trigger_ht_element *trigger_ht_element = nullptr;
        struct cds_lfht_node *node;
        const char *trigger_name;
        bool free_trigger = true;
-       struct lttng_evaluation *evaluation = NULL;
+       struct lttng_evaluation *evaluation = nullptr;
        struct lttng_credentials object_creds;
        uid_t object_uid;
        gid_t object_gid;
        enum action_executor_status executor_status;
        const uint64_t trigger_tracer_token = state->trigger_id.next_tracer_token++;
 
-       rcu_read_lock();
+       lttng::urcu::read_lock_guard read_lock;
 
        /* Set the trigger's tracer token. */
        lttng_trigger_set_tracer_token(trigger, trigger_tracer_token);
@@ -2812,7 +2804,7 @@ handle_notification_thread_command_register_trigger(struct notification_thread_s
         * Ownership of the trigger and of its wrapper was transfered to
         * the triggers_ht. Same for token ht element if necessary.
         */
-       trigger_ht_element = NULL;
+       trigger_ht_element = nullptr;
        free_trigger = false;
 
        switch (get_condition_binding_object(condition)) {
@@ -2887,7 +2879,7 @@ handle_notification_thread_command_register_trigger(struct notification_thread_s
                LTTNG_OPTIONAL_SET(&object_creds.uid, session_info->uid);
                LTTNG_OPTIONAL_SET(&object_creds.gid, session_info->gid);
 
-               ret = evaluate_session_condition(condition, session_info, NULL, &evaluation);
+               ret = evaluate_session_condition(condition, session_info, nullptr, &evaluation);
                session_info_put(session_info);
                break;
        }
@@ -2924,7 +2916,7 @@ handle_notification_thread_command_register_trigger(struct notification_thread_s
         */
        executor_status = action_executor_enqueue_trigger(
                state->executor, trigger, evaluation, &object_creds, client_list);
-       evaluation = NULL;
+       evaluation = nullptr;
        switch (executor_status) {
        case ACTION_EXECUTOR_STATUS_OK:
                break;
@@ -2973,7 +2965,6 @@ error:
                lttng_trigger_destroy(trigger);
        }
 end:
-       rcu_read_unlock();
        return ret;
 }
 
@@ -2993,22 +2984,27 @@ static void teardown_tracer_notifier(struct notification_thread_state *state,
        struct cds_lfht_iter iter;
        struct notification_trigger_tokens_ht_element *trigger_tokens_ht_element;
 
-       cds_lfht_for_each_entry (state->trigger_tokens_ht, &iter, trigger_tokens_ht_element, node) {
-               if (!lttng_trigger_is_equal(trigger, trigger_tokens_ht_element->trigger)) {
-                       continue;
-               }
+       {
+               lttng::urcu::read_lock_guard read_lock;
 
-               event_notifier_error_accounting_unregister_event_notifier(
-                       trigger_tokens_ht_element->trigger);
+               cds_lfht_for_each_entry (
+                       state->trigger_tokens_ht, &iter, trigger_tokens_ht_element, node) {
+                       if (!lttng_trigger_is_equal(trigger, trigger_tokens_ht_element->trigger)) {
+                               continue;
+                       }
 
-               /* TODO talk to all app and remove it */
-               DBG("Removed trigger from tokens_ht");
-               cds_lfht_del(state->trigger_tokens_ht, &trigger_tokens_ht_element->node);
+                       event_notifier_error_accounting_unregister_event_notifier(
+                               trigger_tokens_ht_element->trigger);
 
-               call_rcu(&trigger_tokens_ht_element->rcu_node,
-                        free_notification_trigger_tokens_ht_element_rcu);
+                       /* TODO talk to all app and remove it */
+                       DBG("Removed trigger from tokens_ht");
+                       cds_lfht_del(state->trigger_tokens_ht, &trigger_tokens_ht_element->node);
 
-               break;
+                       call_rcu(&trigger_tokens_ht_element->rcu_node,
+                                free_notification_trigger_tokens_ht_element_rcu);
+
+                       break;
+               }
        }
 }
 
@@ -3048,11 +3044,11 @@ handle_notification_thread_command_unregister_trigger(struct notification_thread
        struct cds_lfht_iter iter;
        struct cds_lfht_node *triggers_ht_node;
        struct notification_client_list *client_list;
-       struct lttng_trigger_ht_element *trigger_ht_element = NULL;
+       struct lttng_trigger_ht_element *trigger_ht_element = nullptr;
        const struct lttng_condition *condition = lttng_trigger_get_const_condition(trigger);
        enum lttng_error_code cmd_reply;
 
-       rcu_read_lock();
+       lttng::urcu::read_lock_guard read_lock;
 
        cds_lfht_lookup(
                state->triggers_ht, lttng_condition_hash(condition), match_trigger, trigger, &iter);
@@ -3139,7 +3135,7 @@ handle_notification_thread_command_unregister_trigger(struct notification_thread
                /* Put new reference and the hashtable's reference. */
                notification_client_list_put(client_list);
                notification_client_list_put(client_list);
-               client_list = NULL;
+               client_list = nullptr;
        }
 
        /* Remove trigger from triggers_ht. */
@@ -3149,34 +3145,33 @@ handle_notification_thread_command_unregister_trigger(struct notification_thread
        lttng_trigger_destroy(trigger_ht_element->trigger);
        call_rcu(&trigger_ht_element->rcu_node, free_lttng_trigger_ht_element_rcu);
 end:
-       rcu_read_unlock();
        if (_cmd_reply) {
                *_cmd_reply = cmd_reply;
        }
        return 0;
 }
 
-static int pop_cmd_queue(struct notification_thread_handle *handle,
-                        struct notification_thread_command **cmd)
+static notification_thread_command *pop_cmd_queue(notification_thread_handle *handle)
 {
-       int ret;
-       uint64_t counter;
+       lttng::pthread::lock_guard queue_lock(handle->cmd_queue.lock);
 
-       pthread_mutex_lock(&handle->cmd_queue.lock);
-       ret = lttng_read(handle->cmd_queue.event_fd, &counter, sizeof(counter));
-       if (ret != sizeof(counter)) {
-               ret = -1;
-               goto error_unlock;
+       uint64_t counter;
+       const auto read_ret = lttng_read(handle->cmd_queue.event_fd, &counter, sizeof(counter));
+       if (read_ret != sizeof(counter)) {
+               if (read_ret < 0) {
+                       LTTNG_THROW_POSIX("Failed to read counter value from event_fd", errno);
+               } else {
+                       LTTNG_THROW_ERROR(lttng::format(
+                               "Failed to read counter value from event_fd because of a truncated read: ret={}, expected read size={}",
+                               read_ret,
+                               sizeof(counter)));
+               }
        }
 
-       *cmd = cds_list_first_entry(
+       auto command = cds_list_first_entry(
                &handle->cmd_queue.list, struct notification_thread_command, cmd_list_node);
-       cds_list_del(&((*cmd)->cmd_list_node));
-       ret = 0;
-
-error_unlock:
-       pthread_mutex_unlock(&handle->cmd_queue.lock);
-       return ret;
+       cds_list_del(&((command)->cmd_list_node));
+       return command;
 }
 
 /* Returns 0 on success, 1 on exit requested, negative value on error. */
@@ -3184,10 +3179,12 @@ int handle_notification_thread_command(struct notification_thread_handle *handle
                                       struct notification_thread_state *state)
 {
        int ret;
-       struct notification_thread_command *cmd;
+       struct notification_thread_command *cmd = nullptr;
 
-       ret = pop_cmd_queue(handle, &cmd);
-       if (ret) {
+       try {
+               cmd = pop_cmd_queue(handle);
+       } catch (const std::exception& ex) {
+               ERR("Failed to get next notification thread command: %s", ex.what());
                goto error;
        }
 
@@ -3259,7 +3256,7 @@ int handle_notification_thread_command(struct notification_thread_handle *handle
                break;
        case NOTIFICATION_COMMAND_TYPE_LIST_TRIGGERS:
        {
-               struct lttng_triggers *triggers = NULL;
+               struct lttng_triggers *triggers = nullptr;
 
                ret = handle_notification_thread_command_list_triggers(
                        handle,
@@ -3277,7 +3274,7 @@ int handle_notification_thread_command(struct notification_thread_handle *handle
                goto end;
        case NOTIFICATION_COMMAND_TYPE_GET_TRIGGER:
        {
-               struct lttng_trigger *trigger = NULL;
+               struct lttng_trigger *trigger = nullptr;
 
                ret = handle_notification_thread_command_get_trigger(
                        state, cmd->parameters.get_trigger.trigger, &trigger, &cmd->reply_code);
@@ -3292,7 +3289,7 @@ int handle_notification_thread_command(struct notification_thread_handle *handle
                        cmd->parameters.client_communication_update.id;
                struct notification_client *client;
 
-               rcu_read_lock();
+               lttng::urcu::read_lock_guard read_lock;
                client = get_client_from_id(client_id, state);
 
                if (!client) {
@@ -3307,7 +3304,6 @@ int handle_notification_thread_command(struct notification_thread_handle *handle
                } else {
                        ret = client_handle_transmission_status(client, client_status, state);
                }
-               rcu_read_unlock();
                break;
        }
        default:
@@ -3318,21 +3314,26 @@ int handle_notification_thread_command(struct notification_thread_handle *handle
        if (ret) {
                goto error_unlock;
        }
+
 end:
-       if (cmd->is_async) {
-               free(cmd);
-               cmd = NULL;
-       } else {
-               lttng_waiter_wake_up(&cmd->reply_waiter);
+       if (cmd) {
+               if (cmd->is_async) {
+                       delete cmd;
+                       cmd = nullptr;
+               } else {
+                       cmd->command_completed_waker->wake();
+               }
        }
+
        return ret;
+
 error_unlock:
        /* Wake-up and return a fatal error to the calling thread. */
-       lttng_waiter_wake_up(&cmd->reply_waiter);
        cmd->reply_code = LTTNG_ERR_FATAL;
+
 error:
-       /* Indicate a fatal error to the caller. */
-       return -1;
+       ret = -1;
+       goto end;
 }
 
 static int socket_set_non_blocking(int socket)
@@ -3388,7 +3389,7 @@ int handle_notification_thread_client_connect(struct notification_thread_state *
                goto error;
        }
 
-       pthread_mutex_init(&client->lock, NULL);
+       pthread_mutex_init(&client->lock, nullptr);
        client->id = state->next_notification_client_id++;
        CDS_INIT_LIST_HEAD(&client->condition_list);
        lttng_payload_init(&client->communication.inbound.payload);
@@ -3434,12 +3435,16 @@ int handle_notification_thread_client_connect(struct notification_thread_state *
        }
        DBG("Added new notification channel client socket (%i) to poll set", client->socket);
 
-       rcu_read_lock();
-       cds_lfht_add(state->client_socket_ht,
-                    hash_client_socket(client->socket),
-                    &client->client_socket_ht_node);
-       cds_lfht_add(state->client_id_ht, hash_client_id(client->id), &client->client_id_ht_node);
-       rcu_read_unlock();
+       {
+               lttng::urcu::read_lock_guard read_lock;
+
+               cds_lfht_add(state->client_socket_ht,
+                            hash_client_socket(client->socket),
+                            &client->client_socket_ht_node);
+               cds_lfht_add(state->client_id_ht,
+                            hash_client_id(client->id),
+                            &client->client_id_ht_node);
+       }
 
        return ret;
 
@@ -3475,7 +3480,7 @@ static int notification_thread_client_disconnect(struct notification_client *cli
        /* Release all conditions to which the client was subscribed. */
        cds_list_for_each_entry_safe (condition_list_element, tmp, &client->condition_list, node) {
                (void) notification_thread_client_unsubscribe(
-                       client, condition_list_element->condition, state, NULL);
+                       client, condition_list_element->condition, state, nullptr);
        }
 
        /*
@@ -3492,7 +3497,8 @@ int handle_notification_thread_client_disconnect(int client_socket,
        int ret = 0;
        struct notification_client *client;
 
-       rcu_read_lock();
+       lttng::urcu::read_lock_guard read_lock;
+
        DBG("Closing client connection (socket fd = %i)", client_socket);
        client = get_client_from_socket(client_socket, state);
        if (!client) {
@@ -3504,7 +3510,6 @@ int handle_notification_thread_client_disconnect(int client_socket,
 
        ret = notification_thread_client_disconnect(client, state);
 end:
-       rcu_read_unlock();
        return ret;
 }
 
@@ -3514,17 +3519,22 @@ int handle_notification_thread_client_disconnect_all(struct notification_thread_
        struct notification_client *client;
        bool error_encoutered = false;
 
-       rcu_read_lock();
        DBG("Closing all client connections");
-       cds_lfht_for_each_entry (state->client_socket_ht, &iter, client, client_socket_ht_node) {
-               int ret;
 
-               ret = notification_thread_client_disconnect(client, state);
-               if (ret) {
-                       error_encoutered = true;
+       {
+               lttng::urcu::read_lock_guard read_lock;
+
+               cds_lfht_for_each_entry (
+                       state->client_socket_ht, &iter, client, client_socket_ht_node) {
+                       int ret;
+
+                       ret = notification_thread_client_disconnect(client, state);
+                       if (ret) {
+                               error_encoutered = true;
+                       }
                }
        }
-       rcu_read_unlock();
+
        return error_encoutered ? 1 : 0;
 }
 
@@ -3534,15 +3544,14 @@ int handle_notification_thread_trigger_unregister_all(struct notification_thread
        struct cds_lfht_iter iter;
        struct lttng_trigger_ht_element *trigger_ht_element;
 
-       rcu_read_lock();
+       lttng::urcu::read_lock_guard read_lock;
        cds_lfht_for_each_entry (state->triggers_ht, &iter, trigger_ht_element, node) {
                int ret = handle_notification_thread_command_unregister_trigger(
-                       state, trigger_ht_element->trigger, NULL);
+                       state, trigger_ht_element->trigger, nullptr);
                if (ret) {
                        error_occurred = true;
                }
        }
-       rcu_read_unlock();
        return error_occurred ? -1 : 0;
 }
 
@@ -3833,7 +3842,7 @@ static int client_handle_message_unknown(struct notification_client *client,
                                            msg->size);
 
        /* msg is not valid anymore due to lttng_dynamic_buffer_set_size. */
-       msg = NULL;
+       msg = nullptr;
 end:
        return ret;
 }
@@ -4016,7 +4025,7 @@ int handle_notification_thread_client_in(struct notification_thread_state *state
        ssize_t recv_ret;
        size_t offset;
 
-       rcu_read_lock();
+       lttng::urcu::read_lock_guard read_lock;
        client = get_client_from_socket(socket, state);
        if (!client) {
                /* Internal error, abort. */
@@ -4101,7 +4110,6 @@ receive_fds:
        }
 
 end:
-       rcu_read_unlock();
        return ret;
 
 error_disconnect_client:
@@ -4116,7 +4124,7 @@ int handle_notification_thread_client_out(struct notification_thread_state *stat
        struct notification_client *client;
        enum client_transmission_status transmission_status;
 
-       rcu_read_lock();
+       lttng::urcu::read_lock_guard read_lock;
        client = get_client_from_socket(socket, state);
        if (!client) {
                /* Internal error, abort. */
@@ -4173,7 +4181,6 @@ int handle_notification_thread_client_out(struct notification_thread_state *stat
                goto end;
        }
 end:
-       rcu_read_unlock();
        return ret;
 }
 
@@ -4541,8 +4548,8 @@ recv_one_event_notifier_notification(int notification_pipe_read_fd, enum lttng_d
 {
        int ret;
        uint64_t token;
-       struct lttng_event_notifier_notification *notification = NULL;
-       char *capture_buffer = NULL;
+       struct lttng_event_notifier_notification *notification = nullptr;
+       char *capture_buffer = nullptr;
        size_t capture_buffer_size;
        void *reception_buffer;
        size_t reception_size;
@@ -4592,7 +4599,7 @@ recv_one_event_notifier_notification(int notification_pipe_read_fd, enum lttng_d
        }
 
        if (capture_buffer_size == 0) {
-               capture_buffer = NULL;
+               capture_buffer = nullptr;
                goto skip_capture;
        }
 
@@ -4619,14 +4626,14 @@ recv_one_event_notifier_notification(int notification_pipe_read_fd, enum lttng_d
 skip_capture:
        notification = lttng_event_notifier_notification_create(
                token, domain, capture_buffer, capture_buffer_size);
-       if (notification == NULL) {
+       if (notification == nullptr) {
                goto end;
        }
 
        /*
         * Ownership transfered to the lttng_event_notifier_notification object.
         */
-       capture_buffer = NULL;
+       capture_buffer = nullptr;
 
 end:
        free(capture_buffer);
@@ -4640,14 +4647,14 @@ dispatch_one_event_notifier_notification(struct notification_thread_state *state
        struct cds_lfht_node *node;
        struct cds_lfht_iter iter;
        struct notification_trigger_tokens_ht_element *element;
-       struct lttng_evaluation *evaluation = NULL;
+       struct lttng_evaluation *evaluation = nullptr;
        enum action_executor_status executor_status;
-       struct notification_client_list *client_list = NULL;
+       struct notification_client_list *client_list = nullptr;
        int ret;
        unsigned int capture_count = 0;
 
        /* Find triggers associated with this token. */
-       rcu_read_lock();
+       lttng::urcu::read_lock_guard read_lock;
        cds_lfht_lookup(state->trigger_tokens_ht,
                        hash_key_u64(&notification->tracer_token, lttng_ht_seed),
                        match_trigger_token,
@@ -4688,7 +4695,7 @@ dispatch_one_event_notifier_notification(struct notification_thread_state *state
                notification->capture_buf_size,
                false);
 
-       if (evaluation == NULL) {
+       if (evaluation == nullptr) {
                ERR("Failed to create event rule matches evaluation while creating and enqueuing action executor job");
                ret = -1;
                goto end_unlock;
@@ -4697,7 +4704,7 @@ dispatch_one_event_notifier_notification(struct notification_thread_state *state
        client_list = get_client_list_from_condition(
                state, lttng_trigger_get_const_condition(element->trigger));
        executor_status = action_executor_enqueue_trigger(
-               state->executor, element->trigger, evaluation, NULL, client_list);
+               state->executor, element->trigger, evaluation, nullptr, client_list);
        switch (executor_status) {
        case ACTION_EXECUTOR_STATUS_OK:
                ret = 0;
@@ -4760,7 +4767,6 @@ dispatch_one_event_notifier_notification(struct notification_thread_state *state
 
 end_unlock:
        notification_client_list_put(client_list);
-       rcu_read_unlock();
 end:
        return ret;
 }
@@ -4770,10 +4776,10 @@ static int handle_one_event_notifier_notification(struct notification_thread_sta
                                                  enum lttng_domain_type domain)
 {
        int ret = 0;
-       struct lttng_event_notifier_notification *notification = NULL;
+       struct lttng_event_notifier_notification *notification = nullptr;
 
        notification = recv_one_event_notifier_notification(pipe, domain);
-       if (notification == NULL) {
+       if (notification == nullptr) {
                /* Reception failed, don't consider it fatal. */
                ERR("Error receiving an event notifier notification from tracer: fd = %i, domain = %s",
                    pipe,
@@ -4807,7 +4813,7 @@ int handle_notification_thread_channel_sample(struct notification_thread_state *
 {
        int ret = 0;
        struct lttcomm_consumer_channel_monitor_msg sample_msg;
-       struct channel_info *channel_info = NULL;
+       struct channel_info *channel_info = nullptr;
        struct cds_lfht_node *node;
        struct cds_lfht_iter iter;
        struct lttng_channel_trigger_list *channel_trigger_list;
@@ -4819,6 +4825,7 @@ int handle_notification_thread_channel_sample(struct notification_thread_state *
        struct lttng_credentials channel_creds = {};
        struct lttng_credentials session_creds = {};
        struct session_info *session;
+       lttng::urcu::read_lock_guard read_lock;
 
        /*
         * The monitoring pipe only holds messages smaller than PIPE_BUF,
@@ -4837,8 +4844,6 @@ int handle_notification_thread_channel_sample(struct notification_thread_state *
        channel_new_sample.highest_usage = sample_msg.highest;
        channel_new_sample.lowest_usage = sample_msg.lowest;
 
-       rcu_read_lock();
-
        session = get_session_info_by_id(state, sample_msg.session_id);
        if (!session) {
                DBG("Received a sample for an unknown session from consumerd: session id = %" PRIu64,
@@ -4858,8 +4863,8 @@ int handle_notification_thread_channel_sample(struct notification_thread_state *
        cds_list_for_each_entry (trigger_list_element, &session_trigger_list->list, node) {
                const struct lttng_condition *condition;
                struct lttng_trigger *trigger;
-               struct notification_client_list *client_list = NULL;
-               struct lttng_evaluation *evaluation = NULL;
+               struct notification_client_list *client_list = nullptr;
+               struct lttng_evaluation *evaluation = nullptr;
                enum action_executor_status executor_status;
 
                ret = 0;
@@ -4886,7 +4891,7 @@ int handle_notification_thread_channel_sample(struct notification_thread_state *
                executor_status = action_executor_enqueue_trigger(
                        state->executor, trigger, evaluation, &session_creds, client_list);
                notification_client_list_put(client_list);
-               evaluation = NULL;
+               evaluation = nullptr;
                switch (executor_status) {
                case ACTION_EXECUTOR_STATUS_OK:
                        break;
@@ -5003,8 +5008,8 @@ int handle_notification_thread_channel_sample(struct notification_thread_state *
        cds_list_for_each_entry (trigger_list_element, &channel_trigger_list->list, node) {
                const struct lttng_condition *condition;
                struct lttng_trigger *trigger;
-               struct notification_client_list *client_list = NULL;
-               struct lttng_evaluation *evaluation = NULL;
+               struct notification_client_list *client_list = nullptr;
+               struct lttng_evaluation *evaluation = nullptr;
                enum action_executor_status executor_status;
 
                ret = 0;
@@ -5016,7 +5021,7 @@ int handle_notification_thread_channel_sample(struct notification_thread_state *
                        condition,
                        &evaluation,
                        state,
-                       previous_sample_available ? &channel_previous_sample : NULL,
+                       previous_sample_available ? &channel_previous_sample : nullptr,
                        &channel_new_sample,
                        channel_info);
                if (caa_unlikely(ret)) {
@@ -5036,7 +5041,7 @@ int handle_notification_thread_channel_sample(struct notification_thread_state *
                executor_status = action_executor_enqueue_trigger(
                        state->executor, trigger, evaluation, &channel_creds, client_list);
                notification_client_list_put(client_list);
-               evaluation = NULL;
+               evaluation = nullptr;
                switch (executor_status) {
                case ACTION_EXECUTOR_STATUS_OK:
                        break;
@@ -5068,7 +5073,6 @@ end_unlock:
                session->last_state_sample = session_new_sample;
        }
        session_info_put(session);
-       rcu_read_unlock();
 end:
        return ret;
 }
This page took 0.043473 seconds and 4 git commands to generate.