X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=blobdiff_plain;f=src%2Fbin%2Flttng-sessiond%2Fmanage-kernel.cpp;fp=src%2Fbin%2Flttng-sessiond%2Fmanage-kernel.cpp;h=74bcb1322e868284b788e2c4d279f0481b03a6d8;hp=49730f497654fe1af8d09be8f6920fa41bce1620;hb=56047f5a23df5c2c583a102b8015bbec5a7da9f1;hpb=66cefebdc240cbae0bc79594305f509b0779fa98 diff --git a/src/bin/lttng-sessiond/manage-kernel.cpp b/src/bin/lttng-sessiond/manage-kernel.cpp index 49730f497..74bcb1322 100644 --- a/src/bin/lttng-sessiond/manage-kernel.cpp +++ b/src/bin/lttng-sessiond/manage-kernel.cpp @@ -16,6 +16,7 @@ #include "utils.hpp" #include +#include #include namespace { @@ -94,12 +95,14 @@ static int update_kernel_stream(int fd) if (!session_get(session)) { continue; } + session_lock(session); 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) { @@ -127,20 +130,25 @@ static int update_kernel_stream(int fd) 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); }