static bool shutdown_health_management_thread(void *data) { struct thread_notifiers *notifiers = data; const int write_fd = lttng_pipe_get_writefd(notifiers->quit_pipe); return notify_thread_pipe(write_fd) == 1; }
static int run_command_wait(struct notification_thread_handle *handle, struct notification_thread_command *cmd) { int ret; uint64_t notification_counter = 1; pthread_mutex_lock(&handle->cmd_queue.lock); /* Add to queue. */ cds_list_add_tail(&cmd->cmd_list_node, &handle->cmd_queue.list); /* Wake-up thread. */ ret = write(lttng_pipe_get_writefd(handle->cmd_queue.event_pipe), ¬ification_counter, sizeof(notification_counter)); if (ret < 0) { PERROR("write to notification thread's queue event fd"); /* * Remove the command from the list so the notification * thread does not process it. */ cds_list_del(&cmd->cmd_list_node); goto error_unlock_queue; } pthread_mutex_unlock(&handle->cmd_queue.lock); lttng_waiter_wait(&cmd->reply_waiter); return 0; error_unlock_queue: pthread_mutex_unlock(&handle->cmd_queue.lock); return -1; }