Change the UST event hash table match function
[lttng-tools.git] / src / bin / lttng-sessiond / filter.c
index e012cb8a1ded65a5958174355152d16af7c09774..d37773d490039de66bcff8dc6be900a4eef4ec96 100644 (file)
@@ -46,6 +46,7 @@ static int add_ufilter_to_event(struct ltt_ust_session *usess, int domain,
        }
        /* Same layout. */
        uevent->filter = (struct lttng_ust_filter_bytecode *) bytecode;
+       uevent->filter->seqnum = usess->filter_seq_num;
 
        switch (domain) {
        case LTTNG_DOMAIN_UST:
@@ -54,6 +55,7 @@ static int add_ufilter_to_event(struct ltt_ust_session *usess, int domain,
                if (ret < 0) {
                        goto error;
                }
+               usess->filter_seq_num++;
                break;
        default:
                ret = -ENOSYS;
@@ -73,10 +75,10 @@ error:
  * Add UST context to tracer.
  */
 int filter_ust_set(struct ltt_ust_session *usess, int domain,
-               struct lttng_filter_bytecode *bytecode, char *event_name,
+               struct lttng_filter_bytecode *bytecode, struct lttng_event *event,
                char *channel_name)
 {
-       int ret = LTTCOMM_OK, have_event = 0;
+       int ret = LTTNG_OK, have_event = 0;
        struct lttng_ht_iter iter;
        struct lttng_ht *chan_ht;
        struct ltt_ust_channel *uchan = NULL;
@@ -96,12 +98,12 @@ int filter_ust_set(struct ltt_ust_session *usess, int domain,
        case LTTNG_DOMAIN_UST_PID_FOLLOW_CHILDREN:
 #endif
        default:
-               ret = LTTCOMM_UND;
+               ret = LTTNG_ERR_UND;
                goto error;
        }
 
-       /* Do we have an event name */
-       if (strlen(event_name) != 0) {
+       /* Do we have a valid event. */
+       if (event && event->name[0] != '\0') {
                have_event = 1;
        }
 
@@ -109,16 +111,17 @@ int filter_ust_set(struct ltt_ust_session *usess, int domain,
        if (strlen(channel_name) != 0) {
                uchan = trace_ust_find_channel_by_name(chan_ht, channel_name);
                if (uchan == NULL) {
-                       ret = LTTCOMM_UST_CHAN_NOT_FOUND;
+                       ret = LTTNG_ERR_UST_CHAN_NOT_FOUND;
                        goto error;
                }
        }
 
        /* If UST channel specified and event name, get UST event ref */
        if (uchan && have_event) {
-               uevent = trace_ust_find_event_by_name(uchan->events, event_name);
+               uevent = trace_ust_find_event(uchan->events, event->name, bytecode,
+                               event->loglevel);
                if (uevent == NULL) {
-                       ret = LTTCOMM_UST_EVENT_NOT_FOUND;
+                       ret = LTTNG_ERR_UST_EVENT_NOT_FOUND;
                        goto error;
                }
        }
@@ -130,12 +133,13 @@ int filter_ust_set(struct ltt_ust_session *usess, int domain,
                                        bytecode);
        } else if (uchan && !have_event) {      /* Add filter to channel */
                ERR("Cannot add filter to channel");
-               ret = LTTCOMM_FATAL;    /* not supported. */
+               ret = LTTNG_ERR_FATAL;  /* not supported. */
                goto error;
        } else if (!uchan && have_event) {      /* Add filter to event */
                /* Add context to event without having the channel name */
                cds_lfht_for_each_entry(chan_ht->ht, &iter.iter, uchan, node.node) {
-                       uevent = trace_ust_find_event_by_name(uchan->events, event_name);
+                       uevent = trace_ust_find_event(uchan->events, event->name, bytecode,
+                                       event->loglevel);
                        if (uevent != NULL) {
                                ret = add_ufilter_to_event(usess, domain, uchan, uevent, bytecode);
                                /*
@@ -146,30 +150,34 @@ int filter_ust_set(struct ltt_ust_session *usess, int domain,
                                goto end;
                        }
                }
-               ret = LTTCOMM_UST_EVENT_NOT_FOUND;
+               ret = LTTNG_ERR_UST_EVENT_NOT_FOUND;
                goto error;
        } else if (!uchan && !have_event) {     /* Add filter all events, all channels */
                ERR("Cannot add filter to channel");
-               ret = LTTCOMM_FATAL;    /* not supported. */
+               ret = LTTNG_ERR_FATAL;  /* not supported. */
                goto error;
        }
 
 end:
+       /* Must handle both local internal error and UST code. */
        switch (ret) {
        case -EEXIST:
-               ret = LTTCOMM_FILTER_EXIST;
+       case -LTTNG_UST_ERR_EXIST:
+               ret = LTTNG_ERR_FILTER_EXIST;
                break;
        case -ENOMEM:
-               ret = LTTCOMM_FATAL;
+               ret = LTTNG_ERR_FATAL;
                break;
        case -EINVAL:
-               ret = LTTCOMM_FILTER_INVAL;
+       case -LTTNG_UST_ERR_INVAL:
+               ret = LTTNG_ERR_FILTER_INVAL;
                break;
        case -ENOSYS:
-               ret = LTTCOMM_UNKNOWN_DOMAIN;
+       case -LTTNG_UST_ERR_NOSYS:
+               ret = LTTNG_ERR_UNKNOWN_DOMAIN;
                break;
        default:
-               ret = LTTCOMM_OK;
+               ret = LTTNG_OK;
                break;
        }
 
This page took 0.024907 seconds and 4 git commands to generate.