X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=blobdiff_plain;f=src%2Fcommon%2Fconsumer.c;h=2ee6c331318a844f675013b691a30e4fc34079f5;hp=363fa4eda6c5ba0dc75296d4c9f7d764c80b21da;hb=a6ba4fe1a8217fd5cb9e286b4d88a9252c0d5d06;hpb=7735ef9e674217413a63bd4a09a93ac0958fe58a diff --git a/src/common/consumer.c b/src/common/consumer.c index 363fa4eda..2ee6c3313 100644 --- a/src/common/consumer.c +++ b/src/common/consumer.c @@ -201,6 +201,25 @@ void consumer_destroy_relayd(struct consumer_relayd_sock_pair *relayd) call_rcu(&relayd->node.head, consumer_rcu_free_relayd); } +/* + * Flag a relayd socket pair for destruction. Destroy it if the refcount + * reaches zero. + * + * RCU read side lock MUST be aquired before calling this function. + */ +void consumer_flag_relayd_for_destroy(struct consumer_relayd_sock_pair *relayd) +{ + assert(relayd); + + /* Set destroy flag for this object */ + uatomic_set(&relayd->destroy_flag, 1); + + /* Destroy the relayd if refcount is 0 */ + if (uatomic_read(&relayd->refcount) == 0) { + consumer_destroy_relayd(relayd); + } +} + /* * Remove a stream from the global list protected by a mutex. This * function is also responsible for freeing its data structures.