Refactoring: introduce list head from enabler getter
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Wed, 3 Nov 2021 18:59:51 +0000 (14:59 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Wed, 3 Nov 2021 18:59:51 +0000 (14:59 -0400)
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: Ib97b1063ccc63d2c1dbeb6f4ea204667afce9a1a

include/lttng/events-internal.h
src/lttng-events.c

index ee052dd1fb8056e6f87af1bfdf26099136feae95..21d887f03f80f65410809540e6ae9e4543ac01d1 100644 (file)
@@ -614,6 +614,27 @@ struct lttng_event_ht *lttng_get_event_ht_from_enabler(struct lttng_event_enable
        }
 }
 
+static inline
+struct list_head *lttng_get_event_list_head_from_enabler(struct lttng_event_enabler_common *event_enabler)
+{
+       switch (event_enabler->enabler_type) {
+       case LTTNG_EVENT_ENABLER_TYPE_RECORDER:
+       {
+               struct lttng_event_recorder_enabler *event_recorder_enabler =
+                       container_of(event_enabler, struct lttng_event_recorder_enabler, parent);
+               return &event_recorder_enabler->chan->parent.session->priv->events;
+       }
+       case LTTNG_EVENT_ENABLER_TYPE_NOTIFIER:
+       {
+               struct lttng_event_notifier_enabler *event_notifier_enabler =
+                       container_of(event_enabler, struct lttng_event_notifier_enabler, parent);
+               return &event_notifier_enabler->group->event_notifiers_head;
+       }
+       default:
+               return NULL;
+       }
+}
+
 int lttng_context_init(void);
 void lttng_context_exit(void);
 int lttng_kernel_context_append(struct lttng_kernel_ctx **ctx_p,
index 7f7748dc54b2e0de50294dabac9577d6c6272fed..fa151acfb15ad8f4a30bb206a09bee5e5a6fb962 100644 (file)
@@ -2231,9 +2231,9 @@ static
 int lttng_event_enabler_ref_events(struct lttng_event_recorder_enabler *event_enabler)
 {
        struct lttng_kernel_channel_buffer *chan = event_enabler->chan;
-       struct lttng_kernel_session *session = event_enabler->chan->parent.session;
        struct lttng_event_enabler_common *base_enabler = lttng_event_recorder_enabler_as_enabler(event_enabler);
        struct lttng_kernel_event_recorder_private *event_recorder_priv;
+       struct list_head *event_list_head = lttng_get_event_list_head_from_enabler(&event_enabler->parent);
 
        if (base_enabler->event_param.instrumentation == LTTNG_KERNEL_ABI_SYSCALL &&
                        base_enabler->event_param.u.syscall.abi == LTTNG_KERNEL_ABI_SYSCALL_ABI_ALL &&
@@ -2253,7 +2253,7 @@ int lttng_event_enabler_ref_events(struct lttng_event_recorder_enabler *event_en
        lttng_create_event_if_missing(&event_enabler->parent);
 
        /* For each event matching event_enabler in session event list. */
-       list_for_each_entry(event_recorder_priv, &session->priv->events, parent.node) {
+       list_for_each_entry(event_recorder_priv, event_list_head, parent.node) {
                struct lttng_kernel_event_recorder *event_recorder = event_recorder_priv->pub;
                struct lttng_enabler_ref *enabler_ref;
 
@@ -2295,6 +2295,7 @@ int lttng_event_notifier_enabler_ref_event_notifiers(
        struct lttng_event_notifier_group *event_notifier_group = event_notifier_enabler->group;
        struct lttng_event_enabler_common *base_enabler = lttng_event_notifier_enabler_as_enabler(event_notifier_enabler);
        struct lttng_kernel_event_notifier_private *event_notifier_priv;
+       struct list_head *event_list_head = lttng_get_event_list_head_from_enabler(&event_notifier_enabler->parent);
 
        if (base_enabler->event_param.instrumentation == LTTNG_KERNEL_ABI_SYSCALL &&
                        base_enabler->event_param.u.syscall.abi == LTTNG_KERNEL_ABI_SYSCALL_ABI_ALL &&
@@ -2316,7 +2317,7 @@ int lttng_event_notifier_enabler_ref_event_notifiers(
        lttng_create_event_if_missing(&event_notifier_enabler->parent);
 
        /* Link the created event_notifier with its associated enabler. */
-       list_for_each_entry(event_notifier_priv, &event_notifier_group->event_notifiers_head, parent.node) {
+       list_for_each_entry(event_notifier_priv, event_list_head, parent.node) {
                struct lttng_kernel_event_notifier *event_notifier = event_notifier_priv->pub;
                struct lttng_enabler_ref *enabler_ref;
 
This page took 0.029239 seconds and 4 git commands to generate.