Fix: Don't set filter if enable event fails
authorDavid Goulet <dgoulet@efficios.com>
Fri, 9 Nov 2012 18:36:02 +0000 (13:36 -0500)
committerDavid Goulet <dgoulet@efficios.com>
Fri, 9 Nov 2012 18:36:31 +0000 (13:36 -0500)
Furthermore, the session daemon now returns an already exist error if
the event is enabled twice. Since we can now set filter, it's misleading
the user to tell him/her that the event was enabled but the filter
failed and than disabling the already enabled event by a previous
command.

Fixes #363 #364

Signed-off-by: David Goulet <dgoulet@efficios.com>
src/bin/lttng-sessiond/ust-app.c
src/bin/lttng/commands/enable_events.c

index 8b1665a06568de2bc90a4a90e61b40e35af4800c..fc0d53787dd6a5d0ff2d8fe9faf5714bc2362951 100644 (file)
@@ -712,10 +712,6 @@ int create_ust_event(struct ust_app *app, struct ust_app_session *ua_sess,
        ret = ustctl_create_event(app->sock, &ua_event->attr, ua_chan->obj,
                        &ua_event->obj);
        if (ret < 0) {
-               if (ret == -EEXIST || ret == -EPERM) {
-                       ret = 0;
-                       goto error;
-               }
                ERR("Error ustctl create event %s for app pid: %d with ret %d",
                                ua_event->attr.name, app->pid, ret);
                goto error;
index 51388298954768d35990b38e540617fc008e4020..4a76267baada7f23619b89517a510afff69be0ee 100644 (file)
@@ -301,6 +301,7 @@ int loglevel_str_to_value(const char *inputstr)
 static int enable_events(char *session_name)
 {
        int err, ret = CMD_SUCCESS, warn = 0;
+       unsigned int event_enabled = 0;
        char *event_name, *channel_name = NULL;
        struct lttng_event ev;
        struct lttng_domain dom;
@@ -366,6 +367,9 @@ static int enable_events(char *session_name)
                        }
                }
 
+               /* Reset flag before enabling a new event. */
+               event_enabled = 0;
+
                ret = lttng_enable_event(handle, &ev, channel_name);
                if (ret < 0) {
                        switch (-ret) {
@@ -380,6 +384,7 @@ static int enable_events(char *session_name)
                        }
                        goto end;
                }
+               event_enabled = 1;
 
                switch (opt_event_type) {
                case LTTNG_EVENT_TRACEPOINT:
@@ -416,10 +421,11 @@ static int enable_events(char *session_name)
                         */
                        goto error;
                }
-               if (opt_filter) {
+               if (opt_filter && event_enabled) {
                        ret = lttng_set_event_filter(handle, ev.name, channel_name,
                                                opt_filter);
                        if (ret < 0) {
+                               fprintf(stderr, "Ret filter: %d\n", ret);
                                switch (-ret) {
                                case LTTNG_ERR_FILTER_EXIST:
                                        WARN("Filter on events is already enabled"
@@ -558,6 +564,9 @@ static int enable_events(char *session_name)
                        goto error;
                }
 
+               /* Reset flag before enabling a new event. */
+               event_enabled = 0;
+
                ret = lttng_enable_event(handle, &ev, channel_name);
                if (ret < 0) {
                        /* Turn ret to positive value to handle the positive error code */
@@ -575,8 +584,9 @@ static int enable_events(char *session_name)
                } else {
                        MSG("%s event %s created in channel %s",
                                        opt_kernel ? "kernel": "UST", event_name, channel_name);
+                       event_enabled = 1;
                }
-               if (opt_filter) {
+               if (opt_filter && event_enabled) {
                        ret = lttng_set_event_filter(handle, ev.name, channel_name,
                                        opt_filter);
                        if (ret < 0) {
This page took 0.038348 seconds and 4 git commands to generate.