X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;f=src%2Fcommon%2Fconsumer-metadata-cache.c;h=d597e64e37883c91182bcaf9c54327cd9cc0d54f;hb=447e8ad9216e708f1698e05dabfdaacc7b3196cf;hp=173cac04976a95f77ff35e128e594324f3c2f240;hpb=04ef1097c8f54a151c899c1773ac56907c97694d;p=lttng-tools.git diff --git a/src/common/consumer-metadata-cache.c b/src/common/consumer-metadata-cache.c index 173cac049..d597e64e3 100644 --- a/src/common/consumer-metadata-cache.c +++ b/src/common/consumer-metadata-cache.c @@ -190,7 +190,7 @@ void consumer_metadata_cache_destroy(struct lttng_consumer_channel *channel) * Return 0 if everything has been flushed, 1 if there is data not flushed. */ int consumer_metadata_cache_flushed(struct lttng_consumer_channel *channel, - uint64_t offset) + uint64_t offset, int timer) { int ret = 0; struct lttng_consumer_stream *metadata_stream; @@ -199,12 +199,16 @@ int consumer_metadata_cache_flushed(struct lttng_consumer_channel *channel, assert(channel->metadata_cache); /* - * XXX This consumer_data.lock should eventually be replaced by - * a channel lock. It protects metadata_stream read and endpoint - * status check. + * If not called from a timer handler, we have to take the + * channel lock to be mutually exclusive with channel teardown. + * Timer handler does not need to take this lock because it is + * already synchronized by timer stop (and, more importantly, + * taking this lock in a timer handler would cause a deadlock). */ - pthread_mutex_lock(&consumer_data.lock); - pthread_mutex_lock(&channel->lock); + if (!timer) { + pthread_mutex_lock(&channel->lock); + } + pthread_mutex_lock(&channel->timer_lock); pthread_mutex_lock(&channel->metadata_cache->lock); metadata_stream = channel->metadata_stream; @@ -227,8 +231,10 @@ int consumer_metadata_cache_flushed(struct lttng_consumer_channel *channel, } pthread_mutex_unlock(&channel->metadata_cache->lock); - pthread_mutex_unlock(&channel->lock); - pthread_mutex_unlock(&consumer_data.lock); + pthread_mutex_unlock(&channel->timer_lock); + if (!timer) { + pthread_mutex_unlock(&channel->lock); + } return ret; }