X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=blobdiff_plain;f=src%2Fbin%2Flttng-sessiond%2Faction-executor.c;h=bce7268e5bac05ccf695f5415d06447f2df1ee41;hp=27f0e472305b6a7a3eb5cafbb50fe8057d0392b5;hb=c0e2990d32d1e55c783c7eb3299f23a7ce062270;hpb=429d9187d105883f809576a6f93513b4ae150580 diff --git a/src/bin/lttng-sessiond/action-executor.c b/src/bin/lttng-sessiond/action-executor.c index 27f0e4723..bce7268e5 100644 --- a/src/bin/lttng-sessiond/action-executor.c +++ b/src/bin/lttng-sessiond/action-executor.c @@ -16,13 +16,14 @@ #include #include #include +#include #include #include #include #include #include #include -#include +#include #include #include #include @@ -94,22 +95,13 @@ static const action_executor_handler action_executors[] = { [LTTNG_ACTION_TYPE_GROUP] = action_executor_group_handler, }; -static const char *action_type_names[] = { - [LTTNG_ACTION_TYPE_NOTIFY] = "Notify", - [LTTNG_ACTION_TYPE_START_SESSION] = "Start session", - [LTTNG_ACTION_TYPE_STOP_SESSION] = "Stop session", - [LTTNG_ACTION_TYPE_ROTATE_SESSION] = "Rotate session", - [LTTNG_ACTION_TYPE_SNAPSHOT_SESSION] = "Snapshot session", - [LTTNG_ACTION_TYPE_GROUP] = "Group", -}; - static const char *get_action_name(const struct lttng_action *action) { const enum lttng_action_type action_type = lttng_action_get_type(action); assert(action_type != LTTNG_ACTION_TYPE_UNKNOWN); - return action_type_names[action_type]; + return lttng_action_type_string(action_type); } /* Check if this trigger allowed to interect with a given session. */ @@ -196,9 +188,8 @@ static int action_executor_notify_handler(struct action_executor *executor, const struct lttng_action *action) { return notification_client_list_send_evaluation(work_item->client_list, - lttng_trigger_get_const_condition(work_item->trigger), + work_item->trigger, work_item->evaluation, - lttng_trigger_get_credentials(work_item->trigger), work_item->object_creds.is_set ? &(work_item->object_creds.value) : NULL, @@ -425,9 +416,9 @@ static int action_executor_snapshot_session_handler(struct action_executor *exec session_lock_list(); session = session_find_by_name(session_name); if (!session) { - DBG("Failed to find session `%s` by name while executing `%s` action of trigger `%p`", + DBG("Failed to find session `%s` by name while executing `%s` action of trigger `%s`", session_name, get_action_name(action), - work_item->trigger); + get_trigger_name(work_item->trigger)); goto error_unlock_list; } @@ -501,7 +492,7 @@ static int action_executor_generic_handler(struct action_executor *executor, assert(action_type != LTTNG_ACTION_TYPE_UNKNOWN); - DBG("Executing action `%s` of trigger `%p` action work item %" PRIu64, + DBG("Executing action `%s` of trigger `%s` action work item %" PRIu64, get_action_name(action), get_trigger_name(work_item->trigger), work_item->id); @@ -539,7 +530,8 @@ static void *action_executor_thread(void *_data) assert(executor); - health_register(health_sessiond, HEALTH_SESSIOND_TYPE_ACTION_EXECUTOR); + health_register(the_health_sessiond, + HEALTH_SESSIOND_TYPE_ACTION_EXECUTOR); rcu_register_thread(); rcu_thread_online(); @@ -592,7 +584,7 @@ static void *action_executor_thread(void *_data) rcu_thread_offline(); rcu_unregister_thread(); - health_unregister(health_sessiond); + health_unregister(the_health_sessiond); return NULL; } @@ -601,8 +593,10 @@ static bool shutdown_action_executor_thread(void *_data) { struct action_executor *executor = _data; + pthread_mutex_lock(&executor->work.lock); executor->should_quit = true; pthread_cond_signal(&executor->work.cond); + pthread_mutex_unlock(&executor->work.lock); return true; } @@ -690,7 +684,7 @@ enum action_executor_status action_executor_enqueue( work_item = zmalloc(sizeof(*work_item)); if (!work_item) { - PERROR("Failed to allocate action executor work item on behalf of trigger `%p`", + PERROR("Failed to allocate action executor work item on behalf of trigger `%s`", get_trigger_name(trigger)); executor_status = ACTION_EXECUTOR_STATUS_ERROR; goto error_unlock; @@ -721,15 +715,15 @@ enum action_executor_status action_executor_enqueue( evaluation = NULL; cds_list_add_tail(&work_item->list_node, &executor->work.list); executor->work.pending_count++; - DBG("Enqueued action for trigger `%p` as work item %" PRIu64, + DBG("Enqueued action for trigger `%s` as work item #%" PRIu64, get_trigger_name(trigger), work_item_id); signal = true; error_unlock: - pthread_mutex_unlock(&executor->work.lock); if (signal) { pthread_cond_signal(&executor->work.cond); } + pthread_mutex_unlock(&executor->work.lock); lttng_evaluation_destroy(evaluation); return executor_status;