Fix: duplicated kernel consumer socket locking
authorFrancis Deslauriers <francis.deslauriers@efficios.com>
Fri, 16 Feb 2018 19:48:49 +0000 (14:48 -0500)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Fri, 16 Feb 2018 21:17:00 +0000 (16:17 -0500)
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 <francis.deslauriers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
src/bin/lttng-sessiond/kernel.c

index 2cbed381870a096350a4e8ac77ec39845850d0f1..8892e76dc144f7963be7813647df05e5f9006da1 100644 (file)
@@ -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;
This page took 0.02739 seconds and 5 git commands to generate.