X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=blobdiff_plain;f=src%2Fbin%2Flttng-relayd%2Fctf-trace.cpp;h=cde9f3927e381297b3f3b8bd53a00532ea2f2e98;hp=9e8693333ebda098f02a8943c71016c2b8b2f9a2;hb=HEAD;hpb=28ab034a2c3582d07d3423d2d746731f87d3969f diff --git a/src/bin/lttng-relayd/ctf-trace.cpp b/src/bin/lttng-relayd/ctf-trace.cpp index 9e8693333..cde9f3927 100644 --- a/src/bin/lttng-relayd/ctf-trace.cpp +++ b/src/bin/lttng-relayd/ctf-trace.cpp @@ -14,6 +14,7 @@ #include "stream.hpp" #include +#include #include #include @@ -44,9 +45,9 @@ static void ctf_trace_destroy(struct ctf_trace *trace) ASSERT_RCU_READ_LOCKED(); session_put(trace->session); - trace->session = NULL; + trace->session = nullptr; free(trace->path); - trace->path = NULL; + trace->path = nullptr; call_rcu(&trace->rcu_node, rcu_destroy_ctf_trace); } @@ -120,8 +121,8 @@ static struct ctf_trace *ctf_trace_create(struct relay_session *session, const c lttng_ht_node_init_str(&trace->node, trace->path); trace->session = session; - pthread_mutex_init(&trace->lock, NULL); - pthread_mutex_init(&trace->stream_list_lock, NULL); + pthread_mutex_init(&trace->lock, nullptr); + pthread_mutex_init(&trace->stream_list_lock, nullptr); lttng_ht_add_str(session->ctf_traces_ht, &trace->node); DBG("Created ctf_trace %" PRIu64 " of session \"%s\" from host \"%s\" with path: %s", @@ -134,7 +135,7 @@ end: return trace; error: ctf_trace_put(trace); - return NULL; + return nullptr; } /* @@ -147,9 +148,9 @@ struct ctf_trace *ctf_trace_get_by_path_or_create(struct relay_session *session, { struct lttng_ht_node_str *node; struct lttng_ht_iter iter; - struct ctf_trace *trace = NULL; + struct ctf_trace *trace = nullptr; - rcu_read_lock(); + lttng::urcu::read_lock_guard read_lock; lttng_ht_lookup(session->ctf_traces_ht, subpath, &iter); node = lttng_ht_iter_get_node_str(&iter); if (!node) { @@ -158,10 +159,9 @@ struct ctf_trace *ctf_trace_get_by_path_or_create(struct relay_session *session, } trace = lttng::utils::container_of(node, &ctf_trace::node); if (!ctf_trace_get(trace)) { - trace = NULL; + trace = nullptr; } end: - rcu_read_unlock(); if (!trace) { /* Try to create */ trace = ctf_trace_create(session, subpath); @@ -171,16 +171,15 @@ end: void ctf_trace_put(struct ctf_trace *trace) { - rcu_read_lock(); + lttng::urcu::read_lock_guard read_lock; urcu_ref_put(&trace->ref, ctf_trace_release); - rcu_read_unlock(); } int ctf_trace_close(struct ctf_trace *trace) { struct relay_stream *stream; - rcu_read_lock(); + lttng::urcu::read_lock_guard read_lock; cds_list_for_each_entry_rcu(stream, &trace->stream_list, stream_node) { /* @@ -189,7 +188,6 @@ int ctf_trace_close(struct ctf_trace *trace) */ try_stream_close(stream); } - rcu_read_unlock(); /* * Since all references to the trace are held by its streams, we * don't need to do any self-ref put. @@ -201,15 +199,14 @@ struct relay_viewer_stream *ctf_trace_get_viewer_metadata_stream(struct ctf_trac { struct relay_viewer_stream *vstream; - rcu_read_lock(); + lttng::urcu::read_lock_guard read_lock; vstream = rcu_dereference(trace->viewer_metadata_stream); if (!vstream) { goto end; } if (!viewer_stream_get(vstream)) { - vstream = NULL; + vstream = nullptr; } end: - rcu_read_unlock(); return vstream; }