Clean-up: modernize pretty_xml.cpp
[lttng-tools.git] / src / bin / lttng-sessiond / manage-kernel.cpp
index ac5c819666b652abe442d0c1d54ba412a0b29c17..fe7f21c6fe36774c19a015239baabd3eb7882af4 100644 (file)
 #include "utils.hpp"
 
 #include <common/pipe.hpp>
+#include <common/urcu.hpp>
 #include <common/utils.hpp>
 
+#include <fcntl.h>
+
 namespace {
 struct thread_notifiers {
        struct lttng_pipe *quit_pipe;
@@ -44,7 +47,7 @@ static int update_kernel_poll(struct lttng_poll_event *events)
                        continue;
                }
                session_lock(session);
-               if (session->kernel_session == NULL) {
+               if (session->kernel_session == nullptr) {
                        session_unlock(session);
                        session_put(session);
                        continue;
@@ -94,12 +97,14 @@ static int update_kernel_stream(int fd)
                if (!session_get(session)) {
                        continue;
                }
+
                session_lock(session);
-               if (session->kernel_session == NULL) {
+               if (session->kernel_session == nullptr) {
                        session_unlock(session);
                        session_put(session);
                        continue;
                }
+
                ksess = session->kernel_session;
 
                cds_list_for_each_entry (channel, &ksess->channel_list.head, list) {
@@ -122,25 +127,30 @@ static int update_kernel_stream(int fd)
                         * means that tracing is started so it is safe to send
                         * our updated stream fds.
                         */
-                       if (ksess->consumer_fds_sent != 1 || ksess->consumer == NULL) {
+                       if (ksess->consumer_fds_sent != 1 || ksess->consumer == nullptr) {
                                ret = -1;
                                goto error;
                        }
 
-                       rcu_read_lock();
-                       cds_lfht_for_each_entry (
-                               ksess->consumer->socks->ht, &iter.iter, socket, node.node) {
-                               pthread_mutex_lock(socket->lock);
-                               ret = kernel_consumer_send_channel_streams(
-                                       socket, channel, ksess, session->output_traces ? 1 : 0);
-                               pthread_mutex_unlock(socket->lock);
-                               if (ret < 0) {
-                                       rcu_read_unlock();
-                                       goto error;
+                       {
+                               lttng::urcu::read_lock_guard read_lock;
+
+                               cds_lfht_for_each_entry (
+                                       ksess->consumer->socks->ht, &iter.iter, socket, node.node) {
+                                       pthread_mutex_lock(socket->lock);
+                                       ret = kernel_consumer_send_channel_streams(
+                                               socket,
+                                               channel,
+                                               ksess,
+                                               session->output_traces ? 1 : 0);
+                                       pthread_mutex_unlock(socket->lock);
+                                       if (ret < 0) {
+                                               goto error;
+                                       }
                                }
                        }
-                       rcu_read_unlock();
                }
+
                session_unlock(session);
                session_put(session);
        }
@@ -189,7 +199,7 @@ static void *thread_kernel_management(void *data)
                goto error_testpoint;
        }
 
-       while (1) {
+       while (true) {
                health_code_update();
 
                if (update_poll_flag == 1) {
@@ -303,7 +313,7 @@ error_testpoint:
        }
        health_unregister(the_health_sessiond);
        DBG("Kernel thread dying");
-       return NULL;
+       return nullptr;
 }
 
 static bool shutdown_kernel_management_thread(void *data)
@@ -325,7 +335,7 @@ static void cleanup_kernel_management_thread(void *data)
 bool launch_kernel_management_thread(int kernel_poll_pipe_read_fd)
 {
        struct lttng_pipe *quit_pipe;
-       struct thread_notifiers *notifiers = NULL;
+       struct thread_notifiers *notifiers = nullptr;
        struct lttng_thread *thread;
 
        notifiers = zmalloc<thread_notifiers>();
This page took 0.028901 seconds and 4 git commands to generate.