Clean-up: modernize pretty_xml.cpp
[lttng-tools.git] / src / bin / lttng-sessiond / notification-thread.cpp
index 74e37902db0056d5599fa57dd4da4a72678451ea..72aa08292141c7b8d7439fc3d9579ca8d3183c40 100644 (file)
@@ -6,32 +6,33 @@
  */
 
 #define _LGPL_SOURCE
-#include <lttng/trigger/trigger.h>
-#include <lttng/notification/channel-internal.hpp>
-#include <lttng/notification/notification-internal.hpp>
-#include <lttng/condition/condition-internal.hpp>
-#include <lttng/condition/buffer-usage-internal.hpp>
-#include <common/error.hpp>
-#include <common/config/session-config.hpp>
-#include <common/defaults.hpp>
-#include <common/utils.hpp>
-#include <common/align.hpp>
-#include <common/time.hpp>
-#include <sys/stat.h>
-#include <time.h>
-#include <signal.h>
-
-#include "notification-thread.hpp"
-#include "notification-thread-events.hpp"
-#include "notification-thread-commands.hpp"
-#include "lttng-sessiond.hpp"
 #include "health-sessiond.hpp"
-#include "thread.hpp"
+#include "kernel.hpp"
+#include "lttng-sessiond.hpp"
+#include "notification-thread-commands.hpp"
+#include "notification-thread-events.hpp"
+#include "notification-thread.hpp"
 #include "testpoint.hpp"
+#include "thread.hpp"
 
-#include "kernel.hpp"
+#include <common/align.hpp>
+#include <common/config/session-config.hpp>
+#include <common/defaults.hpp>
+#include <common/error.hpp>
 #include <common/kernel-ctl/kernel-ctl.hpp>
+#include <common/time.hpp>
+#include <common/utils.hpp>
 
+#include <lttng/condition/buffer-usage-internal.hpp>
+#include <lttng/condition/condition-internal.hpp>
+#include <lttng/notification/channel-internal.hpp>
+#include <lttng/notification/notification-internal.hpp>
+#include <lttng/trigger/trigger.h>
+
+#include <signal.h>
+#include <sys/eventfd.h>
+#include <sys/stat.h>
+#include <time.h>
 #include <urcu.h>
 #include <urcu/list.h>
 #include <urcu/rculfhash.h>
@@ -46,8 +47,7 @@ LTTNG_EXPORT int notifier_consumption_paused;
 /*
  * Destroy the thread data previously created by the init function.
  */
-void notification_thread_handle_destroy(
-               struct notification_thread_handle *handle)
+void notification_thread_handle_destroy(struct notification_thread_handle *handle)
 {
        int ret;
 
@@ -59,8 +59,11 @@ void notification_thread_handle_destroy(
        pthread_mutex_destroy(&handle->cmd_queue.lock);
        sem_destroy(&handle->ready);
 
-       if (handle->cmd_queue.event_pipe) {
-               lttng_pipe_destroy(handle->cmd_queue.event_pipe);
+       if (handle->cmd_queue.event_fd >= 0) {
+               ret = close(handle->cmd_queue.event_fd);
+               if (ret < 0) {
+                       PERROR("Failed to close notification command queue event fd");
+               }
        }
        if (handle->channel_monitoring_pipes.ust32_consumer >= 0) {
                ret = close(handle->channel_monitoring_pipes.ust32_consumer);
@@ -85,41 +88,39 @@ end:
        free(handle);
 }
 
-struct notification_thread_handle *notification_thread_handle_create(
-               struct lttng_pipe *ust32_channel_monitor_pipe,
-               struct lttng_pipe *ust64_channel_monitor_pipe,
-               struct lttng_pipe *kernel_channel_monitor_pipe)
+struct notification_thread_handle *
+notification_thread_handle_create(struct lttng_pipe *ust32_channel_monitor_pipe,
+                                 struct lttng_pipe *ust64_channel_monitor_pipe,
+                                 struct lttng_pipe *kernel_channel_monitor_pipe)
 {
        int ret;
        struct notification_thread_handle *handle;
-       struct lttng_pipe *event_pipe = NULL;
+       int event_fd = -1;
 
-       handle = (notification_thread_handle *) zmalloc(sizeof(*handle));
+       handle = zmalloc<notification_thread_handle>();
        if (!handle) {
                goto end;
        }
 
        sem_init(&handle->ready, 0, 0);
 
-       event_pipe = lttng_pipe_open(FD_CLOEXEC);
-       if (!event_pipe) {
-               ERR("event_pipe creation");
+       event_fd = eventfd(0, EFD_CLOEXEC | EFD_SEMAPHORE);
+       if (event_fd < 0) {
+               PERROR("event_fd creation");
                goto error;
        }
 
-       handle->cmd_queue.event_pipe = event_pipe;
-       event_pipe = NULL;
+       handle->cmd_queue.event_fd = event_fd;
 
        CDS_INIT_LIST_HEAD(&handle->cmd_queue.list);
-       ret = pthread_mutex_init(&handle->cmd_queue.lock, NULL);
+       ret = pthread_mutex_init(&handle->cmd_queue.lock, nullptr);
        if (ret) {
                goto error;
        }
 
        if (ust32_channel_monitor_pipe) {
                handle->channel_monitoring_pipes.ust32_consumer =
-                               lttng_pipe_release_readfd(
-                                       ust32_channel_monitor_pipe);
+                       lttng_pipe_release_readfd(ust32_channel_monitor_pipe);
                if (handle->channel_monitoring_pipes.ust32_consumer < 0) {
                        goto error;
                }
@@ -128,8 +129,7 @@ struct notification_thread_handle *notification_thread_handle_create(
        }
        if (ust64_channel_monitor_pipe) {
                handle->channel_monitoring_pipes.ust64_consumer =
-                               lttng_pipe_release_readfd(
-                                       ust64_channel_monitor_pipe);
+                       lttng_pipe_release_readfd(ust64_channel_monitor_pipe);
                if (handle->channel_monitoring_pipes.ust64_consumer < 0) {
                        goto error;
                }
@@ -138,8 +138,7 @@ struct notification_thread_handle *notification_thread_handle_create(
        }
        if (kernel_channel_monitor_pipe) {
                handle->channel_monitoring_pipes.kernel_consumer =
-                               lttng_pipe_release_readfd(
-                                       kernel_channel_monitor_pipe);
+                       lttng_pipe_release_readfd(kernel_channel_monitor_pipe);
                if (handle->channel_monitoring_pipes.kernel_consumer < 0) {
                        goto error;
                }
@@ -150,26 +149,24 @@ struct notification_thread_handle *notification_thread_handle_create(
 end:
        return handle;
 error:
-       lttng_pipe_destroy(event_pipe);
        notification_thread_handle_destroy(handle);
-       return NULL;
+       return nullptr;
 }
 
-static
-char *get_notification_channel_sock_path(void)
+static char *get_notification_channel_sock_path()
 {
        int ret;
        bool is_root = !getuid();
        char *sock_path;
 
-       sock_path = (char *) zmalloc(LTTNG_PATH_MAX);
+       sock_path = calloc<char>(LTTNG_PATH_MAX);
        if (!sock_path) {
                goto error;
        }
 
        if (is_root) {
-               ret = snprintf(sock_path, LTTNG_PATH_MAX,
-                               DEFAULT_GLOBAL_NOTIFICATION_CHANNEL_UNIX_SOCK);
+               ret = snprintf(
+                       sock_path, LTTNG_PATH_MAX, DEFAULT_GLOBAL_NOTIFICATION_CHANNEL_UNIX_SOCK);
                if (ret < 0) {
                        goto error;
                }
@@ -181,9 +178,10 @@ char *get_notification_channel_sock_path(void)
                        goto error;
                }
 
-               ret = snprintf(sock_path, LTTNG_PATH_MAX,
-                               DEFAULT_HOME_NOTIFICATION_CHANNEL_UNIX_SOCK,
-                               home_path);
+               ret = snprintf(sock_path,
+                              LTTNG_PATH_MAX,
+                              DEFAULT_HOME_NOTIFICATION_CHANNEL_UNIX_SOCK,
+                              home_path);
                if (ret < 0) {
                        goto error;
                }
@@ -192,11 +190,10 @@ char *get_notification_channel_sock_path(void)
        return sock_path;
 error:
        free(sock_path);
-       return NULL;
+       return nullptr;
 }
 
-static
-void notification_channel_socket_destroy(int fd)
+static void notification_channel_socket_destroy(int fd)
 {
        int ret;
        char *sock_path = get_notification_channel_sock_path();
@@ -217,14 +214,12 @@ void notification_channel_socket_destroy(int fd)
        }
 }
 
-static
-int notification_channel_socket_create(void)
+static int notification_channel_socket_create()
 {
        int fd = -1, ret;
        char *sock_path = get_notification_channel_sock_path();
 
-       DBG("Creating notification channel UNIX socket at %s",
-                       sock_path);
+       DBG("Creating notification channel UNIX socket at %s", sock_path);
 
        ret = lttcomm_create_unix_sock(sock_path);
        if (ret < 0) {
@@ -243,8 +238,7 @@ int notification_channel_socket_create(void)
        if (getuid() == 0) {
                gid_t gid;
 
-               ret = utils_get_group_id(the_config.tracing_group_name.value,
-                               true, &gid);
+               ret = utils_get_group_id(the_config.tracing_group_name.value, true, &gid);
                if (ret) {
                        /* Default to root group. */
                        gid = 0;
@@ -258,8 +252,7 @@ int notification_channel_socket_create(void)
                }
        }
 
-       DBG("Notification channel UNIX socket created (fd = %i)",
-                       fd);
+       DBG("Notification channel UNIX socket created (fd = %i)", fd);
        free(sock_path);
        return fd;
 error:
@@ -270,10 +263,9 @@ error:
        return ret;
 }
 
-static
-int init_poll_set(struct lttng_poll_event *poll_set,
-               struct notification_thread_handle *handle,
-               int notification_channel_socket)
+static int init_poll_set(struct lttng_poll_event *poll_set,
+                        struct notification_thread_handle *handle,
+                        int notification_channel_socket)
 {
        int ret;
 
@@ -290,28 +282,22 @@ int init_poll_set(struct lttng_poll_event *poll_set,
                goto end;
        }
 
-       ret = lttng_poll_add(poll_set, notification_channel_socket,
-                       LPOLLIN | LPOLLERR | LPOLLHUP | LPOLLRDHUP);
+       ret = lttng_poll_add(poll_set, notification_channel_socket, LPOLLIN | LPOLLRDHUP);
        if (ret < 0) {
                ERR("Failed to add notification channel socket to pollset");
                goto error;
        }
-       ret = lttng_poll_add(poll_set, lttng_pipe_get_readfd(handle->cmd_queue.event_pipe),
-                       LPOLLIN | LPOLLERR);
+       ret = lttng_poll_add(poll_set, handle->cmd_queue.event_fd, LPOLLIN);
        if (ret < 0) {
                ERR("Failed to add notification command queue event fd to pollset");
                goto error;
        }
-       ret = lttng_poll_add(poll_set,
-                       handle->channel_monitoring_pipes.ust32_consumer,
-                       LPOLLIN | LPOLLERR);
+       ret = lttng_poll_add(poll_set, handle->channel_monitoring_pipes.ust32_consumer, LPOLLIN);
        if (ret < 0) {
                ERR("Failed to add ust-32 channel monitoring pipe fd to pollset");
                goto error;
        }
-       ret = lttng_poll_add(poll_set,
-                       handle->channel_monitoring_pipes.ust64_consumer,
-                       LPOLLIN | LPOLLERR);
+       ret = lttng_poll_add(poll_set, handle->channel_monitoring_pipes.ust64_consumer, LPOLLIN);
        if (ret < 0) {
                ERR("Failed to add ust-64 channel monitoring pipe fd to pollset");
                goto error;
@@ -319,9 +305,7 @@ int init_poll_set(struct lttng_poll_event *poll_set,
        if (handle->channel_monitoring_pipes.kernel_consumer < 0) {
                goto end;
        }
-       ret = lttng_poll_add(poll_set,
-                       handle->channel_monitoring_pipes.kernel_consumer,
-                       LPOLLIN | LPOLLERR);
+       ret = lttng_poll_add(poll_set, handle->channel_monitoring_pipes.kernel_consumer, LPOLLIN);
        if (ret < 0) {
                ERR("Failed to add kernel channel monitoring pipe fd to pollset");
                goto error;
@@ -333,54 +317,52 @@ error:
        return ret;
 }
 
-static
-void fini_thread_state(struct notification_thread_state *state)
+static void fini_thread_state(struct notification_thread_state *state)
 {
        int ret;
 
        if (state->client_socket_ht) {
                ret = handle_notification_thread_client_disconnect_all(state);
                LTTNG_ASSERT(!ret);
-               ret = cds_lfht_destroy(state->client_socket_ht, NULL);
+               ret = cds_lfht_destroy(state->client_socket_ht, nullptr);
                LTTNG_ASSERT(!ret);
        }
        if (state->client_id_ht) {
-               ret = cds_lfht_destroy(state->client_id_ht, NULL);
+               ret = cds_lfht_destroy(state->client_id_ht, nullptr);
                LTTNG_ASSERT(!ret);
        }
        if (state->triggers_ht) {
                ret = handle_notification_thread_trigger_unregister_all(state);
                LTTNG_ASSERT(!ret);
-               ret = cds_lfht_destroy(state->triggers_ht, NULL);
+               ret = cds_lfht_destroy(state->triggers_ht, nullptr);
                LTTNG_ASSERT(!ret);
        }
        if (state->channel_triggers_ht) {
-               ret = cds_lfht_destroy(state->channel_triggers_ht, NULL);
+               ret = cds_lfht_destroy(state->channel_triggers_ht, nullptr);
                LTTNG_ASSERT(!ret);
        }
        if (state->channel_state_ht) {
-               ret = cds_lfht_destroy(state->channel_state_ht, NULL);
+               ret = cds_lfht_destroy(state->channel_state_ht, nullptr);
                LTTNG_ASSERT(!ret);
        }
        if (state->notification_trigger_clients_ht) {
-               ret = cds_lfht_destroy(state->notification_trigger_clients_ht,
-                               NULL);
+               ret = cds_lfht_destroy(state->notification_trigger_clients_ht, nullptr);
                LTTNG_ASSERT(!ret);
        }
        if (state->channels_ht) {
-               ret = cds_lfht_destroy(state->channels_ht, NULL);
+               ret = cds_lfht_destroy(state->channels_ht, nullptr);
                LTTNG_ASSERT(!ret);
        }
        if (state->sessions_ht) {
-               ret = cds_lfht_destroy(state->sessions_ht, NULL);
+               ret = cds_lfht_destroy(state->sessions_ht, nullptr);
                LTTNG_ASSERT(!ret);
        }
        if (state->triggers_by_name_uid_ht) {
-               ret = cds_lfht_destroy(state->triggers_by_name_uid_ht, NULL);
+               ret = cds_lfht_destroy(state->triggers_by_name_uid_ht, nullptr);
                LTTNG_ASSERT(!ret);
        }
        if (state->trigger_tokens_ht) {
-               ret = cds_lfht_destroy(state->trigger_tokens_ht, NULL);
+               ret = cds_lfht_destroy(state->trigger_tokens_ht, nullptr);
                LTTNG_ASSERT(!ret);
        }
        /*
@@ -388,12 +370,11 @@ void fini_thread_state(struct notification_thread_state *state)
         * See comment in struct lttng_session_trigger_list.
         */
        if (state->session_triggers_ht) {
-               ret = cds_lfht_destroy(state->session_triggers_ht, NULL);
+               ret = cds_lfht_destroy(state->session_triggers_ht, nullptr);
                LTTNG_ASSERT(!ret);
        }
        if (state->notification_channel_socket >= 0) {
-               notification_channel_socket_destroy(
-                               state->notification_channel_socket);
+               notification_channel_socket_destroy(state->notification_channel_socket);
        }
 
        LTTNG_ASSERT(cds_list_empty(&state->tracer_event_sources_list));
@@ -404,24 +385,21 @@ void fini_thread_state(struct notification_thread_state *state)
        lttng_poll_clean(&state->events);
 }
 
-static
-void mark_thread_as_ready(struct notification_thread_handle *handle)
+static void mark_thread_as_ready(struct notification_thread_handle *handle)
 {
        DBG("Marking notification thread as ready");
        sem_post(&handle->ready);
 }
 
-static
-void wait_until_thread_is_ready(struct notification_thread_handle *handle)
+static void wait_until_thread_is_ready(struct notification_thread_handle *handle)
 {
        DBG("Waiting for notification thread to be ready");
        sem_wait(&handle->ready);
        DBG("Notification thread is ready");
 }
 
-static
-int init_thread_state(struct notification_thread_handle *handle,
-               struct notification_thread_state *state)
+static int init_thread_state(struct notification_thread_handle *handle,
+                            struct notification_thread_state *state)
 {
        int ret;
 
@@ -436,8 +414,7 @@ int init_thread_state(struct notification_thread_handle *handle,
        }
        state->notification_channel_socket = ret;
 
-       ret = init_poll_set(&state->events, handle,
-                       state->notification_channel_socket);
+       ret = init_poll_set(&state->events, handle, state->notification_channel_socket);
        if (ret) {
                goto end;
        }
@@ -449,65 +426,65 @@ int init_thread_state(struct notification_thread_handle *handle,
                goto error;
        }
 
-       state->client_socket_ht = cds_lfht_new(DEFAULT_HT_SIZE, 1, 0,
-                       CDS_LFHT_AUTO_RESIZE | CDS_LFHT_ACCOUNTING, NULL);
+       state->client_socket_ht = cds_lfht_new(
+               DEFAULT_HT_SIZE, 1, 0, CDS_LFHT_AUTO_RESIZE | CDS_LFHT_ACCOUNTING, nullptr);
        if (!state->client_socket_ht) {
                goto error;
        }
 
-       state->client_id_ht = cds_lfht_new(DEFAULT_HT_SIZE, 1, 0,
-                       CDS_LFHT_AUTO_RESIZE | CDS_LFHT_ACCOUNTING, NULL);
+       state->client_id_ht = cds_lfht_new(
+               DEFAULT_HT_SIZE, 1, 0, CDS_LFHT_AUTO_RESIZE | CDS_LFHT_ACCOUNTING, nullptr);
        if (!state->client_id_ht) {
                goto error;
        }
 
-       state->channel_triggers_ht = cds_lfht_new(DEFAULT_HT_SIZE, 1, 0,
-                       CDS_LFHT_AUTO_RESIZE | CDS_LFHT_ACCOUNTING, NULL);
+       state->channel_triggers_ht = cds_lfht_new(
+               DEFAULT_HT_SIZE, 1, 0, CDS_LFHT_AUTO_RESIZE | CDS_LFHT_ACCOUNTING, nullptr);
        if (!state->channel_triggers_ht) {
                goto error;
        }
 
-       state->session_triggers_ht = cds_lfht_new(DEFAULT_HT_SIZE, 1, 0,
-                       CDS_LFHT_AUTO_RESIZE | CDS_LFHT_ACCOUNTING, NULL);
+       state->session_triggers_ht = cds_lfht_new(
+               DEFAULT_HT_SIZE, 1, 0, CDS_LFHT_AUTO_RESIZE | CDS_LFHT_ACCOUNTING, nullptr);
        if (!state->session_triggers_ht) {
                goto error;
        }
 
-       state->channel_state_ht = cds_lfht_new(DEFAULT_HT_SIZE, 1, 0,
-                       CDS_LFHT_AUTO_RESIZE | CDS_LFHT_ACCOUNTING, NULL);
+       state->channel_state_ht = cds_lfht_new(
+               DEFAULT_HT_SIZE, 1, 0, CDS_LFHT_AUTO_RESIZE | CDS_LFHT_ACCOUNTING, nullptr);
        if (!state->channel_state_ht) {
                goto error;
        }
 
-       state->notification_trigger_clients_ht = cds_lfht_new(DEFAULT_HT_SIZE,
-                       1, 0, CDS_LFHT_AUTO_RESIZE | CDS_LFHT_ACCOUNTING, NULL);
+       state->notification_trigger_clients_ht = cds_lfht_new(
+               DEFAULT_HT_SIZE, 1, 0, CDS_LFHT_AUTO_RESIZE | CDS_LFHT_ACCOUNTING, nullptr);
        if (!state->notification_trigger_clients_ht) {
                goto error;
        }
 
-       state->channels_ht = cds_lfht_new(DEFAULT_HT_SIZE,
-                       1, 0, CDS_LFHT_AUTO_RESIZE | CDS_LFHT_ACCOUNTING, NULL);
+       state->channels_ht = cds_lfht_new(
+               DEFAULT_HT_SIZE, 1, 0, CDS_LFHT_AUTO_RESIZE | CDS_LFHT_ACCOUNTING, nullptr);
        if (!state->channels_ht) {
                goto error;
        }
-       state->sessions_ht = cds_lfht_new(DEFAULT_HT_SIZE,
-                       1, 0, CDS_LFHT_AUTO_RESIZE | CDS_LFHT_ACCOUNTING, NULL);
+       state->sessions_ht = cds_lfht_new(
+               DEFAULT_HT_SIZE, 1, 0, CDS_LFHT_AUTO_RESIZE | CDS_LFHT_ACCOUNTING, nullptr);
        if (!state->sessions_ht) {
                goto error;
        }
-       state->triggers_ht = cds_lfht_new(DEFAULT_HT_SIZE,
-                       1, 0, CDS_LFHT_AUTO_RESIZE | CDS_LFHT_ACCOUNTING, NULL);
+       state->triggers_ht = cds_lfht_new(
+               DEFAULT_HT_SIZE, 1, 0, CDS_LFHT_AUTO_RESIZE | CDS_LFHT_ACCOUNTING, nullptr);
        if (!state->triggers_ht) {
                goto error;
        }
-       state->triggers_by_name_uid_ht = cds_lfht_new(DEFAULT_HT_SIZE,
-                       1, 0, CDS_LFHT_AUTO_RESIZE | CDS_LFHT_ACCOUNTING, NULL);
+       state->triggers_by_name_uid_ht = cds_lfht_new(
+               DEFAULT_HT_SIZE, 1, 0, CDS_LFHT_AUTO_RESIZE | CDS_LFHT_ACCOUNTING, nullptr);
        if (!state->triggers_by_name_uid_ht) {
                goto error;
        }
 
-       state->trigger_tokens_ht = cds_lfht_new(DEFAULT_HT_SIZE,
-                       1, 0, CDS_LFHT_AUTO_RESIZE | CDS_LFHT_ACCOUNTING, NULL);
+       state->trigger_tokens_ht = cds_lfht_new(
+               DEFAULT_HT_SIZE, 1, 0, CDS_LFHT_AUTO_RESIZE | CDS_LFHT_ACCOUNTING, nullptr);
        if (!state->trigger_tokens_ht) {
                goto error;
        }
@@ -529,16 +506,16 @@ error:
        return -1;
 }
 
-static
-int handle_channel_monitoring_pipe(int fd, uint32_t revents,
-               struct notification_thread_handle *handle,
-               struct notification_thread_state *state)
+static int handle_channel_monitoring_pipe(int fd,
+                                         uint32_t revents,
+                                         struct notification_thread_handle *handle,
+                                         struct notification_thread_state *state)
 {
        int ret = 0;
        enum lttng_domain_type domain;
 
        if (fd == handle->channel_monitoring_pipes.ust32_consumer ||
-                       fd == handle->channel_monitoring_pipes.ust64_consumer) {
+           fd == handle->channel_monitoring_pipes.ust64_consumer) {
                domain = LTTNG_DOMAIN_UST;
        } else if (fd == handle->channel_monitoring_pipes.kernel_consumer) {
                domain = LTTNG_DOMAIN_KERNEL;
@@ -554,8 +531,7 @@ int handle_channel_monitoring_pipe(int fd, uint32_t revents,
                goto end;
        }
 
-       ret = handle_notification_thread_channel_sample(
-                       state, fd, domain);
+       ret = handle_notification_thread_channel_sample(state, fd, domain);
        if (ret) {
                ERR("Consumer sample handling error occurred");
                ret = -1;
@@ -566,18 +542,17 @@ end:
 }
 
 static int handle_event_notification_pipe(int event_source_fd,
-               enum lttng_domain_type domain,
-               uint32_t revents,
-               struct notification_thread_state *state)
+                                         enum lttng_domain_type domain,
+                                         uint32_t revents,
+                                         struct notification_thread_state *state)
 {
        int ret = 0;
 
        if (revents & (LPOLLERR | LPOLLHUP | LPOLLRDHUP)) {
-               ret = handle_notification_thread_tracer_event_source_died(
-                               state, event_source_fd);
+               ret = handle_notification_thread_tracer_event_source_died(state, event_source_fd);
                if (ret) {
                        ERR("Failed to remove event notification pipe from poll set: fd = %d",
-                                       event_source_fd);
+                           event_source_fd);
                }
                goto end;
        }
@@ -593,11 +568,9 @@ static int handle_event_notification_pipe(int event_source_fd,
                goto end;
        }
 
-       ret = handle_notification_thread_event_notification(
-                       state, event_source_fd, domain);
+       ret = handle_notification_thread_event_notification(state, event_source_fd, domain);
        if (ret) {
-               ERR("Event notification handling error occurred for fd: %d",
-                               event_source_fd);
+               ERR("Event notification handling error occurred for fd: %d", event_source_fd);
                ret = -1;
                goto end;
        }
@@ -610,15 +583,14 @@ end:
  * Return the event source domain type via parameter.
  */
 static bool fd_is_event_notification_source(const struct notification_thread_state *state,
-               int fd,
-               enum lttng_domain_type *domain)
+                                           int fd,
+                                           enum lttng_domain_type *domain)
 {
        struct notification_event_tracer_event_source_element *source_element;
 
        LTTNG_ASSERT(domain);
 
-       cds_list_for_each_entry(source_element,
-                       &state->tracer_event_sources_list, node) {
+       cds_list_for_each_entry (source_element, &state->tracer_event_sources_list, node) {
                if (source_element->fd != fd) {
                        continue;
                }
@@ -634,8 +606,7 @@ static bool fd_is_event_notification_source(const struct notification_thread_sta
  * This thread services notification channel clients and commands received
  * from various lttng-sessiond components over a command queue.
  */
-static
-void *thread_notification(void *data)
+static void *thread_notification(void *data)
 {
        int ret;
        struct notification_thread_handle *handle = (notification_thread_handle *) data;
@@ -698,22 +669,21 @@ void *thread_notification(void *data)
 
                        if (fd == state.notification_channel_socket) {
                                if (revents & LPOLLIN) {
-                                       ret = handle_notification_thread_client_connect(
-                                                       &state);
+                                       ret = handle_notification_thread_client_connect(&state);
                                        if (ret < 0) {
                                                goto error;
                                        }
-                               } else if (revents &
-                                               (LPOLLERR | LPOLLHUP | LPOLLRDHUP)) {
+                               } else if (revents & (LPOLLERR | LPOLLHUP | LPOLLRDHUP)) {
                                        ERR("Notification socket poll error");
                                        goto error;
                                } else {
-                                       ERR("Unexpected poll events %u for notification socket %i", revents, fd);
+                                       ERR("Unexpected poll events %u for notification socket %i",
+                                           revents,
+                                           fd);
                                        goto error;
                                }
-                       } else if (fd == lttng_pipe_get_readfd(handle->cmd_queue.event_pipe)) {
-                               ret = handle_notification_thread_command(handle,
-                                               &state);
+                       } else if (fd == handle->cmd_queue.event_fd) {
+                               ret = handle_notification_thread_command(handle, &state);
                                if (ret < 0) {
                                        DBG("Error encountered while servicing command queue");
                                        goto error;
@@ -721,10 +691,9 @@ void *thread_notification(void *data)
                                        goto exit;
                                }
                        } else if (fd == handle->channel_monitoring_pipes.ust32_consumer ||
-                                       fd == handle->channel_monitoring_pipes.ust64_consumer ||
-                                       fd == handle->channel_monitoring_pipes.kernel_consumer) {
-                               ret = handle_channel_monitoring_pipe(fd,
-                                               revents, handle, &state);
+                                  fd == handle->channel_monitoring_pipes.ust64_consumer ||
+                                  fd == handle->channel_monitoring_pipes.kernel_consumer) {
+                               ret = handle_channel_monitoring_pipe(fd, revents, handle, &state);
                                if (ret) {
                                        goto error;
                                }
@@ -743,23 +712,23 @@ void *thread_notification(void *data)
                                         * receive the notifications to which
                                         * it was subscribing or unsubscribing.
                                         */
-                                       ret = handle_notification_thread_client_disconnect(
-                                                       fd, &state);
+                                       ret = handle_notification_thread_client_disconnect(fd,
+                                                                                          &state);
                                        if (ret) {
                                                goto error;
                                        }
                                } else {
                                        if (revents & LPOLLIN) {
-                                               ret = handle_notification_thread_client_in(
-                                                       &state, fd);
+                                               ret = handle_notification_thread_client_in(&state,
+                                                                                          fd);
                                                if (ret) {
                                                        goto error;
                                                }
                                        }
 
                                        if (revents & LPOLLOUT) {
-                                               ret = handle_notification_thread_client_out(
-                                                       &state, fd);
+                                               ret = handle_notification_thread_client_out(&state,
+                                                                                           fd);
                                                if (ret) {
                                                        goto error;
                                                }
@@ -784,11 +753,10 @@ end:
        rcu_thread_offline();
        rcu_unregister_thread();
        health_unregister(the_health_sessiond);
-       return NULL;
+       return nullptr;
 }
 
-static
-bool shutdown_notification_thread(void *thread_data)
+static bool shutdown_notification_thread(void *thread_data)
 {
        struct notification_thread_handle *handle = (notification_thread_handle *) thread_data;
 
@@ -796,16 +764,12 @@ bool shutdown_notification_thread(void *thread_data)
        return true;
 }
 
-struct lttng_thread *launch_notification_thread(
-               struct notification_thread_handle *handle)
+struct lttng_thread *launch_notification_thread(struct notification_thread_handle *handle)
 {
        struct lttng_thread *thread;
 
-       thread = lttng_thread_create("Notification",
-                       thread_notification,
-                       shutdown_notification_thread,
-                       NULL,
-                       handle);
+       thread = lttng_thread_create(
+               "Notification", thread_notification, shutdown_notification_thread, nullptr, handle);
        if (!thread) {
                goto error;
        }
@@ -818,5 +782,5 @@ struct lttng_thread *launch_notification_thread(
        wait_until_thread_is_ready(handle);
        return thread;
 error:
-       return NULL;
+       return nullptr;
 }
This page took 0.034263 seconds and 4 git commands to generate.