From: Jonathan Rajotte Date: Mon, 12 Apr 2021 19:41:36 +0000 (-0400) Subject: action executor: execute action only if the associated trigger is registered X-Git-Tag: v2.13.0-rc1~84 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=d2a28b277d9a6d5b95a298e400b9f9eab604f6f0;p=lttng-tools.git action executor: execute action only if the associated trigger is registered It was decided that a trigger removal should have immediate effect and not result in a waiting on action queued to be executed. There was two major way to do this: 1) On unregistrer trigger, lock the action executor queue and remove all work-item related to the trigger ebing unregistered. 2) Mark the trigger as "unregistered" and validate its state when a work item is ready for execution. If the trigger is marked as "unregistered", simply consume and skip the work item. To isolate the un-registration and the execution of a work item depending on that trigger, we use the trigger lock to have exclusivity during the execution for that trigger. Signed-off-by: Jonathan Rajotte Signed-off-by: Jérémie Galarneau Change-Id: I9f42a323e0ec0dc51339f39f07536ec8060dc02a --- diff --git a/src/bin/lttng-sessiond/action-executor.c b/src/bin/lttng-sessiond/action-executor.c index 6c828c8f0..f150dbb44 100644 --- a/src/bin/lttng-sessiond/action-executor.c +++ b/src/bin/lttng-sessiond/action-executor.c @@ -593,7 +593,41 @@ static void *action_executor_thread(void *_data) * allowing new items to be queued. */ pthread_mutex_unlock(&executor->work.lock); + + /* Execute item only if a trigger is registered. */ + lttng_trigger_lock(work_item->trigger); + if (!lttng_trigger_is_registered(work_item->trigger)) { + const char *trigger_name = NULL; + uid_t trigger_owner_uid; + enum lttng_trigger_status trigger_status; + + trigger_status = lttng_trigger_get_name( + work_item->trigger, &trigger_name); + switch (trigger_status) { + case LTTNG_TRIGGER_STATUS_OK: + break; + case LTTNG_TRIGGER_STATUS_UNSET: + trigger_name = "(unset)"; + break; + default: + abort(); + } + + trigger_status = lttng_trigger_get_owner_uid( + work_item->trigger, &trigger_owner_uid); + assert(trigger_status == LTTNG_TRIGGER_STATUS_OK); + + DBG("Work item skipped since the associated trigger is no longer registered: work item id = %" PRIu64 ", trigger name = '%s', trigger owner uid = %d", + work_item->id, trigger_name, + (int) trigger_owner_uid); + ret = 0; + goto skip_execute; + } + ret = action_work_item_execute(executor, work_item); + + skip_execute: + lttng_trigger_unlock(work_item->trigger); action_work_item_destroy(work_item); if (ret) { /* Fatal error. */