From: Francis Deslauriers Date: Fri, 16 Feb 2018 19:48:49 +0000 (-0500) Subject: Fix: duplicated kernel consumer socket locking X-Git-Url: http://git.efficios.com/?p=lttng-tools.git;a=commitdiff_plain;h=cafc2c60ea4893d837fe0e9cb0bbe92c02b8cc46 Fix: duplicated kernel consumer socket locking 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 --- 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;