Fix: use lttng_waiter instead of futex in notification thread
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Wed, 17 May 2017 20:03:13 +0000 (16:03 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Fri, 19 May 2017 14:23:58 +0000 (10:23 -0400)
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
src/bin/lttng-sessiond/notification-thread-commands.c
src/bin/lttng-sessiond/notification-thread-commands.h
src/bin/lttng-sessiond/notification-thread-events.c
src/bin/lttng-sessiond/notification-thread.c

index 5483a317f60c28bedd8a5ecf96ac87768d9ed52d..d9fdf01588465a3e826bbc53b3a0e6cb35d29705 100644 (file)
@@ -20,7 +20,6 @@
 #include "notification-thread.h"
 #include "notification-thread-commands.h"
 #include <common/error.h>
-#include <common/futex.h>
 #include <unistd.h>
 #include <stdint.h>
 #include <inttypes.h>
@@ -30,6 +29,7 @@ void init_notification_thread_command(struct notification_thread_command *cmd)
 {
        memset(cmd, 0, sizeof(*cmd));
        CDS_INIT_LIST_HEAD(&cmd->cmd_list_node);
+       lttng_waiter_init(&cmd->reply_waiter);
 }
 
 static
@@ -39,8 +39,6 @@ int run_command_wait(struct notification_thread_handle *handle,
        int ret;
        uint64_t notification_counter = 1;
 
-       futex_nto1_prepare(&cmd->reply_futex);
-
        pthread_mutex_lock(&handle->cmd_queue.lock);
        /* Add to queue. */
        cds_list_add_tail(&cmd->cmd_list_node,
@@ -59,7 +57,7 @@ int run_command_wait(struct notification_thread_handle *handle,
        }
        pthread_mutex_unlock(&handle->cmd_queue.lock);
 
-       futex_nto1_wait(&cmd->reply_futex);
+       lttng_waiter_wait(&cmd->reply_waiter);
        return 0;
 error_unlock_queue:
        pthread_mutex_unlock(&handle->cmd_queue.lock);
index fc7e90bcb95ecf319c89e6bd8979602eddaac0ef..8885d4faf57d639965b3f5326c50d81a9ba7099d 100644 (file)
@@ -22,6 +22,7 @@
 #include <lttng/lttng-error.h>
 #include <urcu/rculfhash.h>
 #include "notification-thread.h"
+#include <common/waiter.h>
 
 struct notification_thread_data;
 struct lttng_trigger;
@@ -65,8 +66,8 @@ struct notification_thread_command {
                } remove_channel;
        } parameters;
 
-       /* Futex on which to wait for command reply (optional). */
-       int32_t reply_futex;
+       /* lttng_waiter on which to wait for command reply (optional). */
+       struct lttng_waiter reply_waiter;
        enum lttng_error_code reply_code;
 };
 
index 8e70baed5196f45ef6c94830e8dc23efb1204ba7..b0657a4c5675dde9d0d86d1478afbeaedf26646a 100644 (file)
@@ -1110,12 +1110,12 @@ int handle_notification_thread_command(
        }
 end:
        cds_list_del(&cmd->cmd_list_node);
-       futex_nto1_wake(&cmd->reply_futex);
+       lttng_waiter_wake_up(&cmd->reply_waiter);
        pthread_mutex_unlock(&handle->cmd_queue.lock);
        return ret;
 error_unlock:
        /* Wake-up and return a fatal error to the calling thread. */
-       futex_nto1_wake(&cmd->reply_futex);
+       lttng_waiter_wake_up(&cmd->reply_waiter);
        pthread_mutex_unlock(&handle->cmd_queue.lock);
        cmd->reply_code = LTTNG_ERR_FATAL;
 error:
index 059e620598b68b2a84e731980d836f14bd7d1002..e0937d8e58eb577d2f088968d7a16299fe5db4c8 100644 (file)
@@ -25,7 +25,6 @@
 #include <common/config/session-config.h>
 #include <common/defaults.h>
 #include <common/utils.h>
-#include <common/futex.h>
 #include <common/align.h>
 #include <common/time.h>
 #include <sys/eventfd.h>
@@ -158,7 +157,6 @@ void notification_thread_handle_destroy(
                struct notification_thread_handle *handle)
 {
        int ret;
-       struct notification_thread_command *cmd, *tmp;
 
        if (!handle) {
                goto end;
@@ -172,15 +170,7 @@ void notification_thread_handle_destroy(
                PERROR("close notification command queue event_fd");
        }
 
-       pthread_mutex_lock(&handle->cmd_queue.lock);
-       /* Purge queue of in-flight commands and mark them as cancelled. */
-       cds_list_for_each_entry_safe(cmd, tmp, &handle->cmd_queue.list,
-                       cmd_list_node) {
-               cds_list_del(&cmd->cmd_list_node);
-               cmd->reply_code = LTTNG_ERR_COMMAND_CANCELLED;
-               futex_nto1_wake(&cmd->reply_futex);
-       }
-       pthread_mutex_unlock(&handle->cmd_queue.lock);
+       assert(cds_list_empty(&handle->cmd_queue.list));
        pthread_mutex_destroy(&handle->cmd_queue.lock);
 
        if (handle->channel_monitoring_pipes.ust32_consumer >= 0) {
This page took 0.031918 seconds and 4 git commands to generate.