From 94a61469bd430d5906b5c976379dd16e32d73933 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Galarneau?= Date: Tue, 9 Jan 2018 17:00:41 -0500 Subject: [PATCH] Fix: channel lock must be taken to check for pending notifications MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérémie Galarneau --- src/lib/lttng-ctl/channel.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/lib/lttng-ctl/channel.c b/src/lib/lttng-ctl/channel.c index 3d48babb7..f2daf0d50 100644 --- a/src/lib/lttng-ctl/channel.c +++ b/src/lib/lttng-ctl/channel.c @@ -215,6 +215,8 @@ lttng_notification_channel_get_next_notification( goto end; } + pthread_mutex_lock(&channel->lock); + if (channel->pending_notifications.count) { struct pending_notification *pending_notification; @@ -232,11 +234,9 @@ lttng_notification_channel_get_next_notification( cds_list_del(&pending_notification->node); channel->pending_notifications.count--; free(pending_notification); - goto end; + goto end_unlock; } - pthread_mutex_lock(&channel->lock); - ret = receive_message(channel); if (ret) { status = LTTNG_NOTIFICATION_CHANNEL_STATUS_ERROR; -- 2.34.1