From cafc2c60ea4893d837fe0e9cb0bbe92c02b8cc46 Mon Sep 17 00:00:00 2001 From: Francis Deslauriers Date: Fri, 16 Feb 2018 14:48:49 -0500 Subject: [PATCH] Fix: duplicated kernel consumer socket locking MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Commit 9d1103e introduced a bug causing a deadlock on snapshot record. Function consumer_snapshot_channel is called with the lock held causing the pthread_mutex_lock call inside to hang forever. Because consumer_snapshot_channel now acquires the lock before using the socket. No need to acquire the lock before calling the function. Signed-off-by: Francis Deslauriers Signed-off-by: Jérémie Galarneau --- src/bin/lttng-sessiond/kernel.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/bin/lttng-sessiond/kernel.c b/src/bin/lttng-sessiond/kernel.c index 2cbed3818..8892e76dc 100644 --- a/src/bin/lttng-sessiond/kernel.c +++ b/src/bin/lttng-sessiond/kernel.c @@ -1029,12 +1029,10 @@ int kernel_snapshot_record(struct ltt_kernel_session *ksess, /* For each channel, ask the consumer to snapshot it. */ cds_list_for_each_entry(chan, &ksess->channel_list.head, list) { - pthread_mutex_lock(socket->lock); ret = consumer_snapshot_channel(socket, chan->fd, output, 0, ksess->uid, ksess->gid, DEFAULT_KERNEL_TRACE_DIR, wait, nb_packets_per_stream); - pthread_mutex_unlock(socket->lock); if (ret < 0) { ret = LTTNG_ERR_KERN_CONSUMER_FAIL; (void) kernel_consumer_destroy_metadata(socket, @@ -1044,11 +1042,9 @@ int kernel_snapshot_record(struct ltt_kernel_session *ksess, } /* Snapshot metadata, */ - pthread_mutex_lock(socket->lock); ret = consumer_snapshot_channel(socket, ksess->metadata->fd, output, 1, ksess->uid, ksess->gid, DEFAULT_KERNEL_TRACE_DIR, wait, 0); - pthread_mutex_unlock(socket->lock); if (ret < 0) { ret = LTTNG_ERR_KERN_CONSUMER_FAIL; goto error_consumer; -- 2.34.1