trigger/action executor: move trigger registration state change to client thread
authorJonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Mon, 12 Apr 2021 20:38:16 +0000 (16:38 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Sun, 18 Apr 2021 23:28:57 +0000 (19:28 -0400)
Set the unregistered state of the sessiond side trigger object in the
client thread since we want to minimize the possibility of the
notification thread being stalled due to a long execution of an action
in the action executor thread.

Stalling the client thread is, comparatively, less harmful.

Signed-off-by: Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I7de875996b430e49ec50896f8b26a75af7993c74

src/bin/lttng-sessiond/cmd.c
src/bin/lttng-sessiond/notification-thread-events.c

index 73773bd137726c4f09cbd4508338f8b391ad8583..c7745abf1485d37f2e651ec8d37490adbb6b85a9 100644 (file)
@@ -4549,6 +4549,7 @@ enum lttng_error_code cmd_unregister_trigger(const struct lttng_credentials *cmd
        const char *trigger_name;
        uid_t trigger_owner;
        enum lttng_trigger_status trigger_status;
+       struct lttng_trigger *sessiond_trigger = NULL;
 
        trigger_status = lttng_trigger_get_name(trigger, &trigger_name);
        trigger_name = trigger_status == LTTNG_TRIGGER_STATUS_OK ? trigger_name : "(unnamed)";
@@ -4576,6 +4577,28 @@ enum lttng_error_code cmd_unregister_trigger(const struct lttng_credentials *cmd
                }
        }
 
+       /* Fetch the sessiond side trigger object. */
+       ret_code = notification_thread_command_get_trigger(
+                       notification_thread, trigger, &sessiond_trigger);
+       if (ret_code != LTTNG_OK) {
+               DBG("Failed to get trigger from notification thread during unregister: trigger name = '%s', trigger owner uid = %d, error code = %d",
+                               trigger_name, (int) trigger_owner, ret_code);
+               goto end;
+       }
+
+       assert(sessiond_trigger);
+
+       /*
+        * From this point on, no matter what, consider the trigger
+        * unregistered.
+        *
+        * We set the unregistered state of the sessiond side trigger object in
+        * the client thread since we want to minimize the possibility of the
+        * notification thread being stalled due to a long execution of an
+        * action that required the trigger lock.
+        */
+       lttng_trigger_set_as_unregistered(sessiond_trigger);
+
        ret_code = notification_thread_command_unregister_trigger(notification_thread,
                                                                  trigger);
        if (ret_code != LTTNG_OK) {
@@ -4600,6 +4623,7 @@ enum lttng_error_code cmd_unregister_trigger(const struct lttng_credentials *cmd
        }
 
 end:
+       lttng_trigger_put(sessiond_trigger);
        return ret_code;
 }
 
index 28e553f44875c59c74f28fc29d1dbd9adf102e54..90fdadd61280bc2452063931ad1c7ca1fc837f8b 100644 (file)
@@ -3049,9 +3049,6 @@ int handle_notification_thread_command_unregister_trigger(
        trigger_ht_element = caa_container_of(triggers_ht_node,
                        struct lttng_trigger_ht_element, node);
 
-       /* From this point, consider the trigger unregistered no matter what. */
-       lttng_trigger_set_as_unregistered(trigger_ht_element->trigger);
-
        /* Remove trigger from channel_triggers_ht. */
        cds_lfht_for_each_entry(state->channel_triggers_ht, &iter, trigger_list,
                        channel_triggers_ht_node) {
This page took 0.037454 seconds and 4 git commands to generate.