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>
char dummy = 'c';
cache->max_offset = offset + len;
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) {
size_ret = lttng_write(channel->metadata_stream->ust_metadata_poll_pipe[1],
&dummy, 1);
if (size_ret < 1) {
#include <common/consumer/consumer-stream.h>
#include <common/consumer/consumer-testpoint.h>
#include <common/align.h>
#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,
struct lttng_consumer_global_data consumer_data = {
.stream_count = 0,
pthread_mutex_lock(&consumer_data.lock);
pthread_mutex_lock(&stream->chan->lock);
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. */
pthread_mutex_lock(&stream->lock);
/* Remove any reference to that stream. */
stream->chan->metadata_stream = NULL;
pthread_mutex_unlock(&stream->lock);
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);
pthread_mutex_unlock(&stream->chan->lock);
pthread_mutex_unlock(&consumer_data.lock);