X-Git-Url: http://git.lttng.org./?a=blobdiff_plain;ds=sidebyside;f=src%2Fcommon%2Fconsumer%2Fconsumer-stream.cpp;h=0742c865296bad5754c074afb88a6ef08eea8a20;hb=refs%2Fheads%2Fmaster;hp=ab9b39111a02580bd176baac55b7c3b95379d123;hpb=56047f5a23df5c2c583a102b8015bbec5a7da9f1;p=lttng-tools.git diff --git a/src/common/consumer/consumer-stream.cpp b/src/common/consumer/consumer-stream.cpp index ab9b39111..0fa4fb214 100644 --- a/src/common/consumer/consumer-stream.cpp +++ b/src/common/consumer/consumer-stream.cpp @@ -23,6 +23,7 @@ #include #include +#include #include #include #include @@ -363,27 +364,19 @@ end_unlock_mutex: int consumer_stream_sync_metadata(struct lttng_consumer_local_data *ctx, uint64_t session_id) { int ret; - struct lttng_consumer_stream *stream = nullptr; - struct lttng_ht_iter iter; - struct lttng_ht *ht; LTTNG_ASSERT(ctx); - /* Ease our life a bit. */ - ht = the_consumer_data.stream_list_ht; - - lttng::urcu::read_lock_guard read_lock; - /* Search the metadata associated with the session id of the given stream. */ - - cds_lfht_for_each_entry_duplicate(ht->ht, - ht->hash_fct(&session_id, lttng_ht_seed), - ht->match_fct, - &session_id, - &iter.iter, - stream, - node_session_id.node) - { + for (auto *stream : lttng::urcu::lfht_filtered_iteration_adapter< + lttng_consumer_stream, + decltype(lttng_consumer_stream::node_session_id), + <tng_consumer_stream::node_session_id, + std::uint64_t>(*the_consumer_data.stream_list_ht->ht, + &session_id, + the_consumer_data.stream_list_ht->hash_fct(&session_id, + lttng_ht_seed), + the_consumer_data.stream_list_ht->match_fct)) { if (!stream->metadata_flag) { continue; } @@ -642,7 +635,7 @@ struct lttng_consumer_stream *consumer_stream_create(struct lttng_consumer_chann { int ret; struct lttng_consumer_stream *stream; - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; stream = zmalloc(); if (stream == nullptr) { @@ -850,7 +843,7 @@ void consumer_stream_close_output(struct lttng_consumer_stream *stream) stream->trace_chunk = nullptr; /* Check and cleanup relayd if needed. */ - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; relayd = consumer_find_relayd(stream->net_seq_idx); if (relayd != nullptr) { consumer_stream_relayd_close(stream, relayd); @@ -873,7 +866,7 @@ void consumer_stream_delete(struct lttng_consumer_stream *stream, struct lttng_h /* Should NEVER be called not in monitor mode. */ LTTNG_ASSERT(stream->chan->monitor); - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; if (ht) { iter.iter.node = &stream->node.node; @@ -1092,7 +1085,7 @@ int consumer_stream_write_index(struct lttng_consumer_stream *stream, LTTNG_ASSERT(stream); LTTNG_ASSERT(element); - lttng::urcu::read_lock_guard read_lock; + const lttng::urcu::read_lock_guard read_lock; if (stream->net_seq_idx != (uint64_t) -1ULL) { struct consumer_relayd_sock_pair *relayd; relayd = consumer_find_relayd(stream->net_seq_idx);