X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=src%2Fbin%2Flttng-sessiond%2Fcmd.c;h=8c13c2dd6aa24414c6a6ee61c3999afe11f68933;hb=49d21f93659c296425c129bc7722bd8255f5c1b1;hp=98e090539af0ecf7755abc2dfe1332b2f116f3fa;hpb=fa64dfb477cac50bb0b8a02fcf6b5a16a426d43b;p=lttng-tools.git diff --git a/src/bin/lttng-sessiond/cmd.c b/src/bin/lttng-sessiond/cmd.c index 98e090539..8c13c2dd6 100644 --- a/src/bin/lttng-sessiond/cmd.c +++ b/src/bin/lttng-sessiond/cmd.c @@ -16,6 +16,7 @@ */ #define _GNU_SOURCE +#define _LGPL_SOURCE #include #include #include @@ -1385,6 +1386,7 @@ end: /* * Command LTTNG_ENABLE_EVENT processed by the client thread. + * We own filter, exclusion, and filter_expression. */ int cmd_enable_event(struct ltt_session *session, struct lttng_domain *domain, char *channel_name, struct lttng_event *event, @@ -1536,6 +1538,10 @@ int cmd_enable_event(struct ltt_session *session, struct lttng_domain *domain, /* At this point, the session and channel exist on the tracer */ ret = event_ust_enable_tracepoint(usess, uchan, event, filter_expression, filter, exclusion); + /* We have passed ownership */ + filter_expression = NULL; + filter = NULL; + exclusion = NULL; if (ret != LTTNG_OK) { goto error; } @@ -1600,6 +1606,9 @@ int cmd_enable_event(struct ltt_session *session, struct lttng_domain *domain, ret = cmd_enable_event(session, &tmp_dom, (char *) default_chan_name, &uevent, filter_expression, filter, NULL, wpipe); + /* We have passed ownership */ + filter_expression = NULL; + filter = NULL; if (ret != LTTNG_OK && ret != LTTNG_ERR_UST_EVENT_ENABLED) { goto error; } @@ -1629,6 +1638,9 @@ int cmd_enable_event(struct ltt_session *session, struct lttng_domain *domain, ret = LTTNG_OK; error: + free(filter_expression); + free(filter); + free(exclusion); rcu_read_unlock(); return ret; } @@ -1848,7 +1860,9 @@ int cmd_start_trace(struct ltt_session *session) * possible to enable channel thus inform the client. */ if (usess && usess->domain_global.channels) { + rcu_read_lock(); nb_chan += lttng_ht_get_count(usess->domain_global.channels); + rcu_read_unlock(); } if (ksession) { nb_chan += ksession->channel_count; @@ -2451,12 +2465,12 @@ ssize_t cmd_list_channels(int domain, struct ltt_session *session, session->ust_session->domain_global.channels); } DBG3("Number of UST global channels %zd", nb_chan); - if (nb_chan <= 0) { + if (nb_chan < 0) { ret = LTTNG_ERR_UST_CHAN_NOT_FOUND; + goto error; } break; default: - *channels = NULL; ret = LTTNG_ERR_UND; goto error; } @@ -2469,10 +2483,6 @@ ssize_t cmd_list_channels(int domain, struct ltt_session *session, } list_lttng_channels(domain, session, *channels); - } else { - *channels = NULL; - /* Ret value was set in the domain switch case */ - goto error; } return nb_chan;