bytecode: initialize all contexts on event notifier group creation
authorFrancis Deslauriers <francis.deslauriers@efficios.com>
Fri, 22 May 2020 22:02:06 +0000 (18:02 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Thu, 26 Nov 2020 18:37:21 +0000 (13:37 -0500)
Rename `lttng_session_context_init()` to `lttng_context_init_all()` so
to reuse the code.

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: If80745677db993c1b38e158785886180d2e60d26

include/lttng/ust-events.h
liblttng-ust/Makefile.am
liblttng-ust/context-internal.h [new file with mode: 0644]
liblttng-ust/lttng-context.c
liblttng-ust/lttng-events.c

index 41164ac348eb1edf14e83960f07027205cb037ca..4e3163c4328faf625bb098df56e291411926d3d0 100644 (file)
@@ -712,8 +712,6 @@ int lttng_channel_disable(struct lttng_channel *channel);
 int lttng_attach_context(struct lttng_ust_context *context_param,
                union ust_args *uargs,
                struct lttng_ctx **ctx, struct lttng_session *session);
-int lttng_session_context_init(struct lttng_ctx **ctx);
-
 void lttng_transport_register(struct lttng_transport *transport);
 void lttng_transport_unregister(struct lttng_transport *transport);
 
@@ -850,6 +848,8 @@ int lttng_enabler_attach_exclusion(struct lttng_enabler *enabler,
 void lttng_enabler_event_link_bytecode(struct lttng_event *event,
                struct lttng_enabler *enabler);
 void lttng_filter_sync_state(struct lttng_bytecode_runtime *runtime);
+int lttng_session_context_init(struct lttng_ctx **ctx);
+
 
 #ifdef __cplusplus
 }
index bd05dfb8d0fda36a8ab7a20c6877c6f47caeadba..98fb2153d3ebafdbe49c67da8f4ebb8c3bb7308e 100644 (file)
@@ -60,6 +60,7 @@ liblttng_ust_runtime_la_SOURCES = \
        lttng-ust-statedump-provider.h \
        ust_lib.c \
        ust_lib.h \
+       context-internal.h \
        context-provider-internal.h \
        tracepoint-internal.h \
        ust-events-internal.h \
diff --git a/liblttng-ust/context-internal.h b/liblttng-ust/context-internal.h
new file mode 100644 (file)
index 0000000..79c8864
--- /dev/null
@@ -0,0 +1,32 @@
+#ifndef _LTTNG_UST_CONTEXT_INTERNAL_H
+#define _LTTNG_UST_CONTEXT_INTERNAL_H
+
+/*
+ * ust-events-internal.h
+ *
+ * Copyright 2020 (c) - Francis Deslauriers <francis.deslauriers@efficios.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <lttng/ust-events.h>
+
+int lttng_context_init_all(struct lttng_ctx **ctx);
+
+#endif /* _LTTNG_UST_CONTEXT_INTERNAL_H */
index fc564b6aa5745bd1fbacb75118fd5619b3077ecf..c457d3e1c71943f45c02c660dc5e8af6aca30f32 100644 (file)
@@ -31,6 +31,8 @@
 #include <string.h>
 #include <assert.h>
 
+#include "context-internal.h"
+
 /*
  * The filter implementation requires that two consecutive "get" for the
  * same context performed by the same thread return the same result.
@@ -400,7 +402,7 @@ field_error:
        return ret;
 }
 
-int lttng_session_context_init(struct lttng_ctx **ctx)
+int lttng_context_init_all(struct lttng_ctx **ctx)
 {
        int ret;
 
@@ -517,3 +519,8 @@ void lttng_context_init(void)
 void lttng_context_exit(void)
 {
 }
+
+int lttng_session_context_init(struct lttng_ctx **ctx)
+{
+       return 0;
+}
index 5941365ab0eb7284398c8b7774edb4706fcf7b27..ac8b2b70f1e097f151d35ae7d7fe7a06914a52d8 100644 (file)
@@ -63,6 +63,7 @@
 #include "lttng-tracer.h"
 #include "lttng-tracer-core.h"
 #include "lttng-ust-statedump.h"
+#include "context-internal.h"
 #include "ust-events-internal.h"
 #include "wait.h"
 #include "../libringbuffer/shm.h"
@@ -154,7 +155,7 @@ struct lttng_session *lttng_session_create(void)
        session = zmalloc(sizeof(struct lttng_session));
        if (!session)
                return NULL;
-       if (lttng_session_context_init(&session->ctx)) {
+       if (lttng_context_init_all(&session->ctx)) {
                free(session);
                return NULL;
        }
@@ -179,6 +180,12 @@ struct lttng_event_notifier_group *lttng_event_notifier_group_create(void)
        if (!event_notifier_group)
                return NULL;
 
+       /* Add all contexts. */
+       if (lttng_context_init_all(&event_notifier_group->ctx)) {
+               free(event_notifier_group);
+               return NULL;
+       }
+
        CDS_INIT_LIST_HEAD(&event_notifier_group->enablers_head);
        CDS_INIT_LIST_HEAD(&event_notifier_group->event_notifiers_head);
        for (i = 0; i < LTTNG_UST_EVENT_NOTIFIER_HT_SIZE; i++)
This page took 0.027478 seconds and 4 git commands to generate.