metadata_stream->priv = buf;
stream_priv = metadata_stream;
metadata_stream->transport = channel->transport;
+ mutex_init(&metadata_stream->lock);
/*
* Since life-time of metadata cache differs from that of
/*
* Ensure we support mutiple get_next / put sequences followed
- * by put_next.
+ * by put_next. The metadata stream lock internally protects
+ * reading the metadata cache. It can indeed be read
+ * concurrently by "get_next_subbuf" and "flush" operations on
+ * the buffer invoked by different processes.
*/
+ mutex_lock(&stream->lock);
WARN_ON(stream->metadata_in < stream->metadata_out);
if (stream->metadata_in != stream->metadata_out)
- return 0;
+ goto end;
len = stream->metadata_cache->metadata_written -
stream->metadata_in;
if (!len)
- return 0;
+ goto end;
reserve_len = min_t(size_t,
stream->transport->ops.packet_avail_size(chan),
len);
ret = reserve_len;
end:
+ mutex_unlock(&stream->lock);
return ret;
}
wait_queue_head_t read_wait; /* Reader buffer-level wait queue */
struct list_head list; /* Stream list */
struct lttng_transport *transport;
+ struct mutex lock;
};
struct lttng_session {