Refactoring: event create: introduce _lttng_event_recorder_metadata_statedump
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Thu, 4 Nov 2021 20:51:34 +0000 (16:51 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Thu, 4 Nov 2021 20:51:34 +0000 (16:51 -0400)
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I03494b121ef036c240f95b6cd9cae37c434452e3

src/lttng-events.c

index 0115debb755299b5f5def36c59338c320780ca57..cd8efff18778808404a9a34aa35ba64860a2c17c 100644 (file)
@@ -73,9 +73,7 @@ static void _lttng_event_destroy(struct lttng_kernel_event_common *event);
 static void _lttng_channel_destroy(struct lttng_kernel_channel_buffer *chan);
 static int _lttng_event_unregister(struct lttng_kernel_event_common *event);
 static
-int _lttng_event_metadata_statedump(struct lttng_kernel_session *session,
-                                 struct lttng_kernel_channel_buffer *chan,
-                                 struct lttng_kernel_event_recorder *event);
+int _lttng_event_recorder_metadata_statedump(struct lttng_kernel_event_common *event);
 static
 int _lttng_session_metadata_statedump(struct lttng_kernel_session *session);
 static
@@ -1163,7 +1161,7 @@ struct lttng_kernel_event_recorder *_lttng_kernel_event_recorder_create(struct l
                WARN_ON_ONCE(!ret);
                ret = try_module_get(event_return->priv->desc->owner);
                WARN_ON_ONCE(!ret);
-               ret = _lttng_event_metadata_statedump(chan->parent.session, chan, event_recorder_return);
+               ret = _lttng_event_recorder_metadata_statedump(event_return);
                WARN_ON_ONCE(ret > 0);
                if (ret) {
                        lttng_kernel_event_free(event_return);
@@ -1243,7 +1241,7 @@ struct lttng_kernel_event_recorder *_lttng_kernel_event_recorder_create(struct l
                ret = -EINVAL;
                goto register_error;
        }
-       ret = _lttng_event_metadata_statedump(chan->parent.session, chan, event_recorder);
+       ret = _lttng_event_recorder_metadata_statedump(event);
        WARN_ON_ONCE(ret > 0);
        if (ret) {
                goto statedump_error;
@@ -3664,12 +3662,19 @@ int _lttng_fields_metadata_statedump(struct lttng_kernel_session *session,
  * transaction.
  */
 static
-int _lttng_event_metadata_statedump(struct lttng_kernel_session *session,
-                                 struct lttng_kernel_channel_buffer *chan,
-                                 struct lttng_kernel_event_recorder *event_recorder)
+int _lttng_event_recorder_metadata_statedump(struct lttng_kernel_event_common *event)
 {
+       struct lttng_kernel_event_recorder *event_recorder;
+       struct lttng_kernel_channel_buffer *chan;
+       struct lttng_kernel_session *session;
        int ret = 0;
 
+       if (event->type != LTTNG_KERNEL_EVENT_TYPE_RECORDER)
+               return 0;
+       event_recorder = container_of(event, struct lttng_kernel_event_recorder, parent);
+       chan = event_recorder->chan;
+       session = chan->parent.session;
+
        if (event_recorder->priv->metadata_dumped || !LTTNG_READ_ONCE(session->active))
                return 0;
        if (chan->priv->channel_type == METADATA_CHANNEL)
@@ -4124,8 +4129,7 @@ skip_session:
        }
 
        list_for_each_entry(event_recorder_priv, &session->priv->events, parent.node) {
-               ret = _lttng_event_metadata_statedump(session, event_recorder_priv->pub->chan,
-                               event_recorder_priv->pub);
+               ret = _lttng_event_recorder_metadata_statedump(&event_recorder_priv->pub->parent);
                if (ret)
                        goto end;
        }
This page took 0.029062 seconds and 4 git commands to generate.