Don't rely on explicit context for filtering
[lttng-ust.git] / liblttng-ust / lttng-events.c
index b6e2ab3972a2c135f9957340f1c9845869c02696..ca8587306c2c37b6c6f93ac7ff7cc39a2bfb13c7 100644 (file)
@@ -262,6 +262,7 @@ int lttng_session_enable(struct lttng_session *session)
                const struct lttng_ctx *ctx;
                const struct lttng_event_field *fields = NULL;
                size_t nr_fields = 0;
+               uint32_t chan_id;
 
                /* don't change it if session stop/restart */
                if (chan->header_type)
@@ -276,12 +277,17 @@ int lttng_session_enable(struct lttng_session *session)
                        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;
                }
@@ -440,7 +446,7 @@ int lttng_desc_match_wildcard_enabler(const struct lttng_event_desc *desc,
                struct lttng_enabler *enabler)
 {
        int loglevel = 0;
-       unsigned int has_loglevel;
+       unsigned int has_loglevel = 0;
 
        assert(enabler->type == LTTNG_ENABLER_WILDCARD);
        /* Compare excluding final '*' */
@@ -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)
This page took 0.024559 seconds and 4 git commands to generate.