Fix: deny the same port for data and control URL
[lttng-tools.git] / src / bin / lttng-sessiond / cmd.c
index 687c06d42d2b7a3bff15338cec62749a3647ab4b..7819002d04472b3f67cfd2501f3f87deb0cf251c 100644 (file)
@@ -380,20 +380,24 @@ static int add_uri_to_consumer(struct consumer_output *consumer,
        case LTTNG_DST_IPV6:
                DBG2("Setting network URI to consumer");
 
-               consumer->type = CONSUMER_DST_NET;
-
-               if ((uri->stype == LTTNG_STREAM_CONTROL &&
+               if (consumer->type == CONSUMER_DST_NET) {
+                       if ((uri->stype == LTTNG_STREAM_CONTROL &&
                                consumer->dst.net.control_isset) ||
                                (uri->stype == LTTNG_STREAM_DATA &&
                                consumer->dst.net.data_isset)) {
-                       ret = LTTNG_ERR_URL_EXIST;
-                       goto error;
+                               ret = LTTNG_ERR_URL_EXIST;
+                               goto error;
+                       }
+               } else {
+                       memset(&consumer->dst.net, 0, sizeof(consumer->dst.net));
                }
 
+               consumer->type = CONSUMER_DST_NET;
+
                /* Set URI into consumer output object */
                ret = consumer_set_network_uri(consumer, uri);
                if (ret < 0) {
-                       ret = LTTNG_ERR_FATAL;
+                       ret = -ret;
                        goto error;
                } else if (ret == 1) {
                        /*
@@ -434,6 +438,8 @@ static int add_uri_to_consumer(struct consumer_output *consumer,
                break;
        }
 
+       ret = LTTNG_OK;
+
 error:
        return ret;
 }
@@ -1642,7 +1648,7 @@ int cmd_set_consumer_uri(int domain, struct ltt_session *session,
 
        for (i = 0; i < nb_uri; i++) {
                ret = add_uri_to_consumer(consumer, &uris[i], domain, session->name);
-               if (ret < 0) {
+               if (ret != LTTNG_OK) {
                        goto error;
                }
        }
@@ -1920,6 +1926,7 @@ ssize_t cmd_list_domains(struct ltt_session *session,
 
        if (session->ust_session != NULL) {
                (*domains)[index].type = LTTNG_DOMAIN_UST;
+               (*domains)[index].buf_type = session->ust_session->buffer_type;
                index++;
        }
 
This page took 0.024696 seconds and 4 git commands to generate.