X-Git-Url: http://git.lttng.org./?a=blobdiff_plain;f=src%2Fcommon%2Fkernel-consumer%2Fkernel-consumer.c;h=b6440bc2aef018102e48dcac2fa20c53b33f86db;hb=90c106c686bee2d1dedf1496140f9291d3b16799;hp=8c0a87737056e4e2e39fa6adadbeb7bccb4305bc;hpb=823a3926b8ecdd9299333b5e7a9dcd0c7ca6aa26;p=lttng-tools.git diff --git a/src/common/kernel-consumer/kernel-consumer.c b/src/common/kernel-consumer/kernel-consumer.c index 8c0a87737..b6440bc2a 100644 --- a/src/common/kernel-consumer/kernel-consumer.c +++ b/src/common/kernel-consumer/kernel-consumer.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2011 Julien Desfossez + * Copyright (C) 2011 EfficiOS Inc. * Copyright (C) 2011 Mathieu Desnoyers * Copyright (C) 2017 Jérémie Galarneau * @@ -139,7 +139,7 @@ error: /* * Take a snapshot of all the stream of a channel * RCU read-side lock must be held across this function to ensure existence of - * channel. The channel lock must be held by the caller. + * channel. * * Returns 0 on success, < 0 on error */ @@ -154,6 +154,9 @@ static int lttng_kconsumer_snapshot_channel( DBG("Kernel consumer snapshot channel %" PRIu64, key); + /* Prevent channel modifications while we perform the snapshot.*/ + pthread_mutex_lock(&channel->lock); + rcu_read_lock(); /* Splice is not supported yet for channel snapshot. */ @@ -347,13 +350,14 @@ end_unlock: pthread_mutex_unlock(&stream->lock); end: rcu_read_unlock(); + pthread_mutex_unlock(&channel->lock); return ret; } /* * Read the whole metadata available for a snapshot. * RCU read-side lock must be held across this function to ensure existence of - * metadata_channel. The channel lock must be held by the caller. + * metadata_channel. * * Returns 0 on success, < 0 on error */ @@ -376,7 +380,7 @@ static int lttng_kconsumer_snapshot_metadata( metadata_stream = metadata_channel->metadata_stream; assert(metadata_stream); - pthread_mutex_lock(&metadata_stream->lock); + metadata_stream->read_subbuffer_ops.lock(metadata_stream); assert(metadata_channel->trace_chunk); assert(metadata_stream->trace_chunk); @@ -431,7 +435,7 @@ static int lttng_kconsumer_snapshot_metadata( ret = 0; error_snapshot: - pthread_mutex_unlock(&metadata_stream->lock); + metadata_stream->read_subbuffer_ops.unlock(metadata_stream); cds_list_del(&metadata_stream->send_node); consumer_stream_destroy(metadata_stream, NULL); metadata_channel->metadata_stream = NULL; @@ -961,7 +965,6 @@ error_streams_sent_nosignal: ERR("Channel %" PRIu64 " not found", key); ret_code = LTTCOMM_CONSUMERD_CHAN_NOT_FOUND; } else { - pthread_mutex_lock(&channel->lock); if (msg.u.snapshot_channel.metadata == 1) { int ret_snapshot; @@ -989,7 +992,6 @@ error_streams_sent_nosignal: ret_code = LTTCOMM_CONSUMERD_SNAPSHOT_FAILED; } } - pthread_mutex_unlock(&channel->lock); } health_code_update(); @@ -1604,17 +1606,10 @@ enum get_next_subbuffer_status get_subbuffer_common( * when there is no data for a finalized stream. Those can be * combined into a -ENODATA return value. */ -<<<<<<< HEAD - if (ret == -EAGAIN) { - ret = -ENODATA; - } - -======= status = GET_NEXT_SUBBUFFER_STATUS_NO_DATA; goto end; default: status = GET_NEXT_SUBBUFFER_STATUS_ERROR; ->>>>>>> ba6c36321 (Clean-up: consumerd: use a specific status code for get_next_subbuffer) goto end; }