X-Git-Url: http://git.lttng.org./?a=blobdiff_plain;f=src%2Fbin%2Flttng-relayd%2Findex.cpp;h=a20ae2658a505cfab8431546e458e960ac83f203;hb=8d5a3312b34841f1ecba2605acad3eaca79fd5e4;hp=f2f102e64d4714d945551435dc5f41e83cb394db;hpb=0f1b1d2510d23e9a2a4baa9e2642ef97a35ef83f;p=lttng-tools.git diff --git a/src/bin/lttng-relayd/index.cpp b/src/bin/lttng-relayd/index.cpp index f2f102e64..a20ae2658 100644 --- a/src/bin/lttng-relayd/index.cpp +++ b/src/bin/lttng-relayd/index.cpp @@ -9,14 +9,14 @@ #define _LGPL_SOURCE -#include -#include -#include +#include +#include +#include -#include "lttng-relayd.h" -#include "stream.h" -#include "index.h" -#include "connection.h" +#include "lttng-relayd.hpp" +#include "stream.hpp" +#include "index.hpp" +#include "connection.hpp" /* * Allocate a new relay index object. Pass the stream in which it is @@ -34,7 +34,7 @@ static struct relay_index *relay_index_create(struct relay_stream *stream, DBG2("Creating relay index for stream id %" PRIu64 " and seqnum %" PRIu64, stream->stream_handle, net_seq_num); - index = (relay_index *) zmalloc(sizeof(*index)); + index = zmalloc(); if (!index) { PERROR("Relay index zmalloc"); goto end; @@ -67,6 +67,8 @@ static struct relay_index *relay_index_add_unique(struct relay_stream *stream, struct cds_lfht_node *node_ptr; struct relay_index *_index; + ASSERT_RCU_READ_LOCKED(); + DBG2("Adding relay index with stream id %" PRIu64 " and seqnum %" PRIu64, stream->stream_handle, index->index_n.key); @@ -88,6 +90,8 @@ static struct relay_index *relay_index_add_unique(struct relay_stream *stream, */ static bool relay_index_get(struct relay_index *index) { + ASSERT_RCU_READ_LOCKED(); + DBG2("index get for stream id %" PRIu64 " and seqnum %" PRIu64 " refcount %d", index->stream->stream_handle, index->index_n.key, (int) index->ref.refcount); @@ -116,7 +120,7 @@ struct relay_index *relay_index_get_by_id_or_create(struct relay_stream *stream, lttng_ht_lookup(stream->indexes_ht, &net_seq_num, &iter); node = lttng_ht_iter_get_node_u64(&iter); if (node) { - index = caa_container_of(node, struct relay_index, index_n); + index = lttng::utils::container_of(node, &relay_index::index_n); } else { struct relay_index *oldindex; @@ -196,7 +200,7 @@ static void index_destroy(struct relay_index *index) static void index_destroy_rcu(struct rcu_head *rcu_head) { struct relay_index *index = - caa_container_of(rcu_head, struct relay_index, rcu_node); + lttng::utils::container_of(rcu_head, &relay_index::rcu_node); index_destroy(index); } @@ -204,7 +208,7 @@ static void index_destroy_rcu(struct rcu_head *rcu_head) /* Stream lock must be held by the caller. */ static void index_release(struct urcu_ref *ref) { - struct relay_index *index = caa_container_of(ref, struct relay_index, ref); + struct relay_index *index = lttng::utils::container_of(ref, &relay_index::ref); struct relay_stream *stream = index->stream; int ret; struct lttng_ht_iter iter;