From 911a481190c7af4c043bb5482152a76e9787c5b5 Mon Sep 17 00:00:00 2001 From: David Goulet Date: Fri, 9 Nov 2012 13:36:02 -0500 Subject: [PATCH] Fix: Don't set filter if enable event fails 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 --- src/bin/lttng-sessiond/ust-app.c | 4 ---- src/bin/lttng/commands/enable_events.c | 14 ++++++++++++-- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/bin/lttng-sessiond/ust-app.c b/src/bin/lttng-sessiond/ust-app.c index 8b1665a06..fc0d53787 100644 --- a/src/bin/lttng-sessiond/ust-app.c +++ b/src/bin/lttng-sessiond/ust-app.c @@ -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; diff --git a/src/bin/lttng/commands/enable_events.c b/src/bin/lttng/commands/enable_events.c index 513882989..4a76267ba 100644 --- a/src/bin/lttng/commands/enable_events.c +++ b/src/bin/lttng/commands/enable_events.c @@ -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) { -- 2.34.1