From: Jérémie Galarneau Date: Mon, 1 Dec 2014 21:15:49 +0000 (-0500) Subject: Fix: Apply consumer URI changes to all domains X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=bda32d5621dc58f49d1e77b6998b53fc976d35d4;p=lttng-tools.git Fix: Apply consumer URI changes to all domains See the associated bug report for a lenghty explanation of the issue and of this fix. It fixes an issue when saving a live session's configuration that was created by loading an .lttng file. Fixes #866 Signed-off-by: Jérémie Galarneau --- diff --git a/src/bin/lttng-sessiond/cmd.c b/src/bin/lttng-sessiond/cmd.c index 696e650de..c1e33693f 100644 --- a/src/bin/lttng-sessiond/cmd.c +++ b/src/bin/lttng-sessiond/cmd.c @@ -2007,13 +2007,12 @@ error: /* * Command LTTNG_SET_CONSUMER_URI processed by the client thread. */ -int cmd_set_consumer_uri(int domain, struct ltt_session *session, - size_t nb_uri, struct lttng_uri *uris) +int cmd_set_consumer_uri(struct ltt_session *session, size_t nb_uri, + struct lttng_uri *uris) { int ret, i; struct ltt_kernel_session *ksess = session->kernel_session; struct ltt_ust_session *usess = session->ust_session; - struct consumer_output *consumer = NULL; assert(session); assert(uris); @@ -2025,41 +2024,41 @@ int cmd_set_consumer_uri(int domain, struct ltt_session *session, goto error; } - /* - * This case switch makes sure the domain session has a temporary consumer - * so the URL can be set. - */ - switch (domain) { - case 0: - /* Code flow error. A session MUST always have a consumer object */ - assert(session->consumer); - /* - * The URL will be added to the tracing session consumer instead of a - * specific domain consumer. - */ - consumer = session->consumer; - break; - case LTTNG_DOMAIN_KERNEL: - /* Code flow error if we don't have a kernel session here. */ - assert(ksess); - assert(ksess->consumer); - consumer = ksess->consumer; - break; - case LTTNG_DOMAIN_UST: - /* Code flow error if we don't have a kernel session here. */ - assert(usess); - assert(usess->consumer); - consumer = usess->consumer; - break; - } - + /* Set the "global" consumer URIs */ for (i = 0; i < nb_uri; i++) { - ret = add_uri_to_consumer(consumer, &uris[i], domain, session->name); + ret = add_uri_to_consumer(session->consumer, + &uris[i], 0, session->name); if (ret != LTTNG_OK) { goto error; } } + /* Set UST session URIs */ + if (session->ust_session) { + for (i = 0; i < nb_uri; i++) { + ret = add_uri_to_consumer( + session->ust_session->consumer, + &uris[i], LTTNG_DOMAIN_UST, + session->name); + if (ret != LTTNG_OK) { + goto error; + } + } + } + + /* Set kernel session URIs */ + if (session->kernel_session) { + for (i = 0; i < nb_uri; i++) { + ret = add_uri_to_consumer( + session->kernel_session->consumer, + &uris[i], LTTNG_DOMAIN_KERNEL, + session->name); + if (ret != LTTNG_OK) { + goto error; + } + } + } + /* * Make sure to set the session in output mode after we set URI since a * session can be created without URL (thus flagged in no output mode). @@ -2067,7 +2066,9 @@ int cmd_set_consumer_uri(int domain, struct ltt_session *session, session->output_traces = 1; if (ksess) { ksess->output_traces = 1; - } else if (usess) { + } + + if (usess) { usess->output_traces = 1; } @@ -2129,7 +2130,7 @@ int cmd_create_session_uri(char *name, struct lttng_uri *uris, } if (uris) { - ret = cmd_set_consumer_uri(0, session, nb_uri, uris); + ret = cmd_set_consumer_uri(session, nb_uri, uris); if (ret != LTTNG_OK) { goto consumer_error; } diff --git a/src/bin/lttng-sessiond/cmd.h b/src/bin/lttng-sessiond/cmd.h index 21ab1c7bb..69c931a38 100644 --- a/src/bin/lttng-sessiond/cmd.h +++ b/src/bin/lttng-sessiond/cmd.h @@ -64,8 +64,8 @@ int cmd_stop_trace(struct ltt_session *session); /* Consumer commands */ int cmd_register_consumer(struct ltt_session *session, int domain, const char *sock_path, struct consumer_data *cdata); -int cmd_set_consumer_uri(int domain, struct ltt_session *session, - size_t nb_uri, struct lttng_uri *uris); +int cmd_set_consumer_uri(struct ltt_session *session, size_t nb_uri, + struct lttng_uri *uris); int cmd_setup_relayd(struct ltt_session *session); /* Listing commands */ diff --git a/src/bin/lttng-sessiond/main.c b/src/bin/lttng-sessiond/main.c index a970012c7..0b116e118 100644 --- a/src/bin/lttng-sessiond/main.c +++ b/src/bin/lttng-sessiond/main.c @@ -3389,31 +3389,12 @@ skip_domain: goto error; } - ret = cmd_set_consumer_uri(cmd_ctx->lsm->domain.type, cmd_ctx->session, - nb_uri, uris); + ret = cmd_set_consumer_uri(cmd_ctx->session, nb_uri, uris); + free(uris); if (ret != LTTNG_OK) { - free(uris); goto error; } - /* - * XXX: 0 means that this URI should be applied on the session. Should - * be a DOMAIN enuam. - */ - if (cmd_ctx->lsm->domain.type == 0) { - /* Add the URI for the UST session if a consumer is present. */ - if (cmd_ctx->session->ust_session && - cmd_ctx->session->ust_session->consumer) { - ret = cmd_set_consumer_uri(LTTNG_DOMAIN_UST, cmd_ctx->session, - nb_uri, uris); - } else if (cmd_ctx->session->kernel_session && - cmd_ctx->session->kernel_session->consumer) { - ret = cmd_set_consumer_uri(LTTNG_DOMAIN_KERNEL, - cmd_ctx->session, nb_uri, uris); - } - } - - free(uris); break; }