sessiond: main.cpp: iterate on list using list_iteration_adapter
[lttng-tools.git] / src / common / consumer / consumer-stream.cpp
index ab9b39111a02580bd176baac55b7c3b95379d123..0fa4fb214488ef6c36d912eaa51203e4994511a9 100644 (file)
@@ -23,6 +23,7 @@
 #include <common/ust-consumer/ust-consumer.hpp>
 #include <common/utils.hpp>
 
+#include <fcntl.h>
 #include <inttypes.h>
 #include <sys/mman.h>
 #include <unistd.h>
@@ -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),
+                    &lttng_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<lttng_consumer_stream>();
        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);
This page took 0.025184 seconds and 4 git commands to generate.