Version 2.2.3
[lttng-ust.git] / liblttng-ust / lttng-events.c
index 78a4f7603de5003fc6af44f47feafdc9d887b669..34c708f6b67b1d7dd2ce3b5248d45635bdd3a9b0 100644 (file)
@@ -45,7 +45,7 @@
 
 #include <usterr-signal-safe.h>
 #include <helper.h>
-#include <ust-ctl.h>
+#include <lttng/ust-ctl.h>
 #include <ust-comm.h>
 #include "error.h"
 #include "compat.h"
@@ -260,8 +260,9 @@ int lttng_session_enable(struct lttng_session *session)
         */
        cds_list_for_each_entry(chan, &session->chan_head, node) {
                const struct lttng_ctx *ctx;
-               const struct lttng_event_field *fields = NULL;
+               const struct lttng_ctx_field *fields = NULL;
                size_t nr_fields = 0;
+               uint32_t chan_id;
 
                /* don't change it if session stop/restart */
                if (chan->header_type)
@@ -269,19 +270,24 @@ int lttng_session_enable(struct lttng_session *session)
                ctx = chan->ctx;
                if (ctx) {
                        nr_fields = ctx->nr_fields;
-                       fields = &ctx->fields->event_field;
+                       fields = ctx->fields;
                }
                ret = ustcomm_register_channel(notify_socket,
                        session->objd,
                        chan->objd,
                        nr_fields,
                        fields,
-                       &chan->id,
+                       &chan_id,
                        &chan->header_type);
                if (ret) {
                        DBG("Error (%d) registering channel to sessiond", ret);
                        return ret;
                }
+               if (chan_id != chan->id) {
+                       DBG("Error: channel registration id (%u) does not match id assigned at creation (%u)",
+                               chan_id, chan->id);
+                       return -EINVAL;
+               }
        }
 
        /* Set atomically the state to "active" */
@@ -365,9 +371,9 @@ int lttng_event_create(const struct lttng_event_desc *desc,
        head = &chan->session->events_ht.table[hash & (LTTNG_UST_EVENT_HT_SIZE - 1)];
        cds_hlist_for_each_entry(event, node, head, hlist) {
                assert(event->desc);
-               if (!strncmp(event->desc->name,
-                               desc->name,
-                               LTTNG_UST_SYM_NAME_LEN - 1)) {
+               if (!strncmp(event->desc->name, desc->name,
+                                       LTTNG_UST_SYM_NAME_LEN - 1)
+                               && chan == event->chan) {
                        ret = -EEXIST;
                        goto exist;
                }
@@ -499,7 +505,11 @@ static
 int lttng_event_match_enabler(struct lttng_event *event,
                struct lttng_enabler *enabler)
 {
-       return lttng_desc_match_enabler(event->desc, enabler);
+       if (lttng_desc_match_enabler(event->desc, enabler)
+                       && event->chan == enabler->chan)
+               return 1;
+       else
+               return 0;
 }
 
 static
@@ -557,7 +567,8 @@ void lttng_create_event_if_missing(struct lttng_enabler *enabler)
                        hash = jhash(event_name, name_len, 0);
                        head = &session->events_ht.table[hash & (LTTNG_UST_EVENT_HT_SIZE - 1)];
                        cds_hlist_for_each_entry(event, node, head, hlist) {
-                               if (event->desc == desc)
+                               if (event->desc == desc
+                                               && event->chan == enabler->chan)
                                        found = 1;
                        }
                        if (found)
@@ -624,12 +635,9 @@ int lttng_enabler_ref_events(struct lttng_enabler *enabler)
 /*
  * Called at library load: connect the probe on all enablers matching
  * this event.
- * called with session mutex held.
- * TODO: currently, for each desc added, we iterate on all event desc
- * (inefficient). We should create specific code that only target the
- * added desc.
+ * Called with session mutex held.
  */
-int lttng_fix_pending_event_desc(const struct lttng_event_desc *desc)
+int lttng_fix_pending_events(void)
 {
        struct lttng_session *session;
 
This page took 0.023814 seconds and 4 git commands to generate.