X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=blobdiff_plain;f=src%2Fbin%2Flttng-sessiond%2Fsnapshot.cpp;fp=src%2Fbin%2Flttng-sessiond%2Fsnapshot.cpp;h=e7a0033541a5d07d5cdafd77d5f4306e462e2662;hp=1b48034c2e9c3a84d11895b6ff7e8dd221bc671b;hb=56047f5a23df5c2c583a102b8015bbec5a7da9f1;hpb=66cefebdc240cbae0bc79594305f509b0779fa98 diff --git a/src/bin/lttng-sessiond/snapshot.cpp b/src/bin/lttng-sessiond/snapshot.cpp index 1b48034c2..e7a003354 100644 --- a/src/bin/lttng-sessiond/snapshot.cpp +++ b/src/bin/lttng-sessiond/snapshot.cpp @@ -10,6 +10,7 @@ #include "utils.hpp" #include +#include #include #include @@ -191,9 +192,8 @@ void snapshot_delete_output(struct snapshot *snapshot, struct snapshot_output *o LTTNG_ASSERT(output); iter.iter.node = &output->node.node; - rcu_read_lock(); + lttng::urcu::read_lock_guard read_lock; ret = lttng_ht_del(snapshot->output_ht, &iter); - rcu_read_unlock(); LTTNG_ASSERT(!ret); /* * This is safe because the ownership of a snapshot object is in a session @@ -211,9 +211,8 @@ void snapshot_add_output(struct snapshot *snapshot, struct snapshot_output *outp LTTNG_ASSERT(snapshot->output_ht); LTTNG_ASSERT(output); - rcu_read_lock(); + lttng::urcu::read_lock_guard read_lock; lttng_ht_add_unique_ulong(snapshot->output_ht, &output->node); - rcu_read_unlock(); /* * This is safe because the ownership of a snapshot object is in a session * for which the session lock need to be acquired to read and modify it. @@ -325,11 +324,14 @@ void snapshot_destroy(struct snapshot *obj) return; } - rcu_read_lock(); - cds_lfht_for_each_entry (obj->output_ht->ht, &iter.iter, output, node.node) { - snapshot_delete_output(obj, output); - snapshot_output_destroy(output); + { + lttng::urcu::read_lock_guard read_lock; + + cds_lfht_for_each_entry (obj->output_ht->ht, &iter.iter, output, node.node) { + snapshot_delete_output(obj, output); + snapshot_output_destroy(output); + } } - rcu_read_unlock(); + lttng_ht_destroy(obj->output_ht); }