Fix: Apply consumer URI changes to all domains
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Mon, 1 Dec 2014 21:15:49 +0000 (16:15 -0500)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Mon, 1 Dec 2014 21:15:49 +0000 (16:15 -0500)
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 <jeremie.galarneau@efficios.com>
src/bin/lttng-sessiond/cmd.c
src/bin/lttng-sessiond/cmd.h
src/bin/lttng-sessiond/main.c

index 696e650debb70e6c0f9724b506a1b1413f0bd3a7..c1e33693f913076d58d8dba938975be23e10d4bc 100644 (file)
@@ -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;
                }
index 21ab1c7bb208b2b478d32f89bbf96fc2b3eb58b3..69c931a38e1814cbd45db36194d4a799398fafd3 100644 (file)
@@ -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 */
index a970012c7fde9fc90464adfd2520add2e6a3a903..0b116e11820ff70ee483c132b2eef4215840a5d9 100644 (file)
@@ -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;
        }
This page took 0.029099 seconds and 4 git commands to generate.