X-Git-Url: https://git.liburcu.org/?a=blobdiff_plain;f=src%2Fcommon%2Fkernel-consumer%2Fkernel-consumer.c;h=362cbd2dca61bde6f23a4375725b172b22f3bb70;hb=8aaed9e719995e6fdc4d87decd1252594d3d80e7;hp=245f4ee46ee552eb60c75b7ca17156ed7ebd8d71;hpb=c1c2a6a67147c81eadc7a9cf241e99d38b7cf1f9;p=lttng-tools.git diff --git a/src/common/kernel-consumer/kernel-consumer.c b/src/common/kernel-consumer/kernel-consumer.c index 245f4ee46..362cbd2dc 100644 --- a/src/common/kernel-consumer/kernel-consumer.c +++ b/src/common/kernel-consumer/kernel-consumer.c @@ -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,8 @@ static int lttng_kconsumer_snapshot_metadata( metadata_stream = metadata_channel->metadata_stream; assert(metadata_stream); - pthread_mutex_lock(&metadata_stream->lock); + /* Take all the appropriate locks hehehe.*/ + metadata_stream->read_subbuffer_ops.lock(metadata_stream); assert(metadata_channel->trace_chunk); assert(metadata_stream->trace_chunk); @@ -431,7 +436,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; @@ -935,7 +940,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) { ret = lttng_kconsumer_snapshot_metadata(channel, key, msg.u.snapshot_channel.pathname, @@ -955,7 +959,6 @@ error_streams_sent_nosignal: ret_code = LTTCOMM_CONSUMERD_SNAPSHOT_FAILED; } } - pthread_mutex_unlock(&channel->lock); } health_code_update();