Clean-up: sessiond: Extract trigger_ht_element removal function
authorFrancis Deslauriers <francis.deslauriers@efficios.com>
Thu, 5 Nov 2020 17:25:44 +0000 (12:25 -0500)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Fri, 2 Apr 2021 19:38:59 +0000 (15:38 -0400)
Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I4994d1dce7a8fc188b6df6ad72e5cd1081cb0cc7

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

index 99b6642d67f972b25860f8a9acf72df4b032f9b2..23e1c13af67281006acdf50d8a627692c363992f 100644 (file)
@@ -2558,6 +2558,18 @@ enum lttng_error_code generate_trigger_name(
        return ret_code;
 }
 
+static inline
+void notif_thread_state_remove_trigger_ht_elem(
+               struct notification_thread_state *state,
+               struct lttng_trigger_ht_element *trigger_ht_element)
+{
+       assert(state);
+       assert(trigger_ht_element);
+
+       cds_lfht_del(state->triggers_ht, &trigger_ht_element->node);
+       cds_lfht_del(state->triggers_by_name_uid_ht, &trigger_ht_element->node_by_name_uid);
+}
+
 /*
  * FIXME A client's credentials are not checked when registering a trigger.
  *
@@ -2669,10 +2681,8 @@ int handle_notification_thread_command_register_trigger(
                if (!trigger_tokens_ht_element) {
                        /* Fatal error. */
                        ret = -1;
-                       cds_lfht_del(state->triggers_ht,
-                                       &trigger_ht_element->node);
-                       cds_lfht_del(state->triggers_by_name_uid_ht,
-                                       &trigger_ht_element->node_by_name_uid);
+                       notif_thread_state_remove_trigger_ht_elem(state,
+                                       trigger_ht_element);
                        goto error_free_ht_element;
                }
 
@@ -2692,10 +2702,8 @@ int handle_notification_thread_command_register_trigger(
                        /* Internal corruption, fatal error. */
                        ret = -1;
                        *cmd_result = LTTNG_ERR_TRIGGER_EXISTS;
-                       cds_lfht_del(state->triggers_ht,
-                                       &trigger_ht_element->node);
-                       cds_lfht_del(state->triggers_by_name_uid_ht,
-                                       &trigger_ht_element->node_by_name_uid);
+                       notif_thread_state_remove_trigger_ht_elem(state,
+                                       trigger_ht_element);
                        goto error_free_ht_element;
                }
 
@@ -2714,9 +2722,10 @@ int handle_notification_thread_command_register_trigger(
                                        *cmd_result = LTTNG_ERR_EVENT_NOTIFIER_REGISTRATION;
                                }
 
-                               cds_lfht_del(state->triggers_ht, &trigger_ht_element->node);
-                               cds_lfht_del(state->triggers_by_name_uid_ht, &trigger_ht_element->node_by_name_uid);
-                               cds_lfht_del(state->trigger_tokens_ht, &trigger_tokens_ht_element->node);
+                               cds_lfht_del(state->trigger_tokens_ht,
+                                               &trigger_tokens_ht_element->node);
+                               notif_thread_state_remove_trigger_ht_elem(state,
+                                               trigger_ht_element);
                                goto error_free_ht_element;
                        }
 
@@ -3025,11 +3034,11 @@ int handle_notification_thread_command_unregister_trigger(
                client_list = NULL;
        }
 
-       /* Remove trigger from triggers_ht. */
        trigger_ht_element = caa_container_of(triggers_ht_node,
                        struct lttng_trigger_ht_element, node);
-       cds_lfht_del(state->triggers_by_name_uid_ht, &trigger_ht_element->node_by_name_uid);
-       cds_lfht_del(state->triggers_ht, triggers_ht_node);
+
+       /* Remove trigger from triggers_ht. */
+       notif_thread_state_remove_trigger_ht_elem(state, trigger_ht_element);
 
        /* Release the ownership of the trigger. */
        lttng_trigger_destroy(trigger_ht_element->trigger);
This page took 0.034873 seconds and 4 git commands to generate.