Fix: JUL filtering for event *
authorDavid Goulet <dgoulet@efficios.com>
Mon, 26 May 2014 18:01:14 +0000 (14:01 -0400)
committerDavid Goulet <dgoulet@efficios.com>
Mon, 26 May 2014 18:01:14 +0000 (14:01 -0400)
Signed-off-by: David Goulet <dgoulet@efficios.com>
src/lib/lttng-ctl/lttng-ctl.c

index 921db6f598fb30195398750f9a906e355e36707e..6363d56b30ad37e8b46b795e02404bdd6120fc41 100644 (file)
@@ -757,7 +757,7 @@ int lttng_enable_event_with_exclusions(struct lttng_handle *handle,
                int exclusion_count, char **exclusion_list)
 {
        struct lttcomm_session_msg lsm;
-       char *varlen_data, *jul_filter = NULL;
+       char *varlen_data;
        int ret = 0;
        struct filter_parser_ctx *ctx = NULL;
        FILE *fmem = NULL;
@@ -817,10 +817,25 @@ int lttng_enable_event_with_exclusions(struct lttng_handle *handle,
        /* Parse filter expression */
        if (filter_expression != NULL || handle->domain.type == LTTNG_DOMAIN_JUL) {
                if (handle->domain.type == LTTNG_DOMAIN_JUL) {
+                       char *jul_filter;
+
                        /* Setup JUL filter if needed. */
-                       filter_expression = set_jul_filter(filter_expression, ev);
-                       if (!filter_expression) {
-                               goto ask_sessiond;
+                       jul_filter = set_jul_filter(filter_expression, ev);
+                       if (!jul_filter) {
+                               if (!filter_expression) {
+                                       /* No JUL and no filter, just skip everything below. */
+                                       goto ask_sessiond;
+                               }
+                       } else {
+                               /*
+                                * With a JUL filter, the original filter has been added to it
+                                * thus replace the filter expression.
+                                */
+                               filter_expression = strdup(jul_filter);
+                               free(jul_filter);
+                               if (!filter_expression) {
+                                       return -LTTNG_ERR_FILTER_NOMEM;
+                               }
                        }
                }
 
@@ -832,7 +847,6 @@ int lttng_enable_event_with_exclusions(struct lttng_handle *handle,
                                strlen(filter_expression), "r");
                if (!fmem) {
                        fprintf(stderr, "Error opening memory as stream\n");
-                       free(jul_filter);
                        return -LTTNG_ERR_FILTER_NOMEM;
                }
                ctx = filter_parser_ctx_alloc(fmem);
@@ -943,7 +957,6 @@ varlen_alloc_error:
                        perror("fclose");
                }
        }
-       free(jul_filter);
        return ret;
 
 parse_error:
@@ -954,7 +967,6 @@ filter_alloc_error:
        if (fclose(fmem) != 0) {
                perror("fclose");
        }
-       free(jul_filter);
        return ret;
 
 ask_sessiond:
This page took 0.026827 seconds and 4 git commands to generate.