Pass lttng_event struct to the set_filter API call
[lttng-tools.git] / src / bin / lttng-sessiond / filter.c
index f0acffdc1dfc3287f6892253f59bc862711cd80c..1088cbed58e34e27fa023b538670075ebc9cc8f9 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,7 +75,7 @@ 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 = LTTNG_OK, have_event = 0;
@@ -100,8 +102,8 @@ int filter_ust_set(struct ltt_ust_session *usess, int domain,
                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;
        }
 
@@ -116,7 +118,7 @@ int filter_ust_set(struct ltt_ust_session *usess, int domain,
 
        /* 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_by_name(uchan->events, event->name);
                if (uevent == NULL) {
                        ret = LTTNG_ERR_UST_EVENT_NOT_FOUND;
                        goto error;
@@ -135,7 +137,7 @@ int filter_ust_set(struct ltt_ust_session *usess, int domain,
        } 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_by_name(uchan->events, event->name);
                        if (uevent != NULL) {
                                ret = add_ufilter_to_event(usess, domain, uchan, uevent, bytecode);
                                /*
@@ -155,17 +157,21 @@ int filter_ust_set(struct ltt_ust_session *usess, int domain,
        }
 
 end:
+       /* Must handle both local internal error and UST code. */
        switch (ret) {
        case -EEXIST:
+       case -LTTNG_UST_ERR_EXIST:
                ret = LTTNG_ERR_FILTER_EXIST;
                break;
        case -ENOMEM:
                ret = LTTNG_ERR_FATAL;
                break;
        case -EINVAL:
+       case -LTTNG_UST_ERR_INVAL:
                ret = LTTNG_ERR_FILTER_INVAL;
                break;
        case -ENOSYS:
+       case -LTTNG_UST_ERR_NOSYS:
                ret = LTTNG_ERR_UNKNOWN_DOMAIN;
                break;
        default:
This page took 0.024272 seconds and 4 git commands to generate.