]> git.lttng.org Git - lttng-tools.git/commitdiff
Fix: protect the channel's metadata stream using the metadata cache lock
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Wed, 21 Dec 2016 22:56:24 +0000 (17:56 -0500)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Fri, 6 Jan 2017 16:38:27 +0000 (11:38 -0500)
The consumer_thread_data_poll and consumer_thread_metadata_poll
both access the channel's metadata stream.

During a session destruction, consumer_thread_metadata_poll will
destroy all metadata streams. However, the consumer_thread_data_poll
may still invoke a consumer_metadata_cache_write() triggered
by a "ready" subbuffer. Hence, the metadata stream must be protected
from this action by the metadata cache lock.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
src/common/consumer/consumer-metadata-cache.c
src/common/consumer/consumer.c

index 3211ec1e84878d7735fe2280891719fd9fd308d6..6b15375e19c27d52ae31b991d13bfc6f52838088 100644 (file)
@@ -147,7 +147,7 @@ int consumer_metadata_cache_write(struct lttng_consumer_channel *channel,
                char dummy = 'c';
 
                cache->max_offset = offset + len;
-               if (channel->monitor) {
+               if (channel->monitor && channel->metadata_stream) {
                        size_ret = lttng_write(channel->metadata_stream->ust_metadata_poll_pipe[1],
                                        &dummy, 1);
                        if (size_ret < 1) {
index 4dec3e80964a4d07212734a18d719209c4a3abc9..47df32958352b2477a84851bd56875a56696d5fc 100644 (file)
@@ -47,6 +47,7 @@
 #include <common/consumer/consumer-stream.h>
 #include <common/consumer/consumer-testpoint.h>
 #include <common/align.h>
+#include <common/consumer/consumer-metadata-cache.h>
 
 struct lttng_consumer_global_data consumer_data = {
        .stream_count = 0,
@@ -2052,6 +2053,7 @@ void consumer_del_metadata_stream(struct lttng_consumer_stream *stream,
 
        pthread_mutex_lock(&consumer_data.lock);
        pthread_mutex_lock(&stream->chan->lock);
+       pthread_mutex_lock(&stream->chan->metadata_cache->lock);
        pthread_mutex_lock(&stream->lock);
 
        /* Remove any reference to that stream. */
@@ -2077,6 +2079,7 @@ void consumer_del_metadata_stream(struct lttng_consumer_stream *stream,
        stream->chan->metadata_stream = NULL;
 
        pthread_mutex_unlock(&stream->lock);
+       pthread_mutex_unlock(&stream->chan->metadata_cache->lock);
        pthread_mutex_unlock(&stream->chan->lock);
        pthread_mutex_unlock(&consumer_data.lock);
 
This page took 0.033237 seconds and 4 git commands to generate.