X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=blobdiff_plain;f=src%2Fbin%2Flttng-sessiond%2Fust-consumer.c;h=aabe49403fbc1215d423986cb7dfa71301da2a47;hp=5b909ab1594609257f1026f7d246c39f43bf8d9c;hb=a4b92340642035d1eafeb1eead0ad01f64d2007d;hpb=37278a1e7efe00011260569fa90909601e8c5184 diff --git a/src/bin/lttng-sessiond/ust-consumer.c b/src/bin/lttng-sessiond/ust-consumer.c index 5b909ab15..aabe49403 100644 --- a/src/bin/lttng-sessiond/ust-consumer.c +++ b/src/bin/lttng-sessiond/ust-consumer.c @@ -117,7 +117,7 @@ error: /* * Send all stream fds of UST channel to the consumer. */ -int ust_consumer_send_channel_streams(int sock, +static int send_channel_streams(int sock, struct ust_app_channel *uchan, struct ust_app_session *usess, struct consumer_output *consumer) { @@ -136,8 +136,8 @@ int ust_consumer_send_channel_streams(int sock, /* Get the right path name destination */ if (consumer->type == CONSUMER_DST_LOCAL) { /* Set application path to the destination path */ - ret = snprintf(tmp_path, sizeof(tmp_path), "%s/%s", - consumer->dst.trace_path, usess->path); + ret = snprintf(tmp_path, sizeof(tmp_path), "%s/%s/%s", + consumer->dst.trace_path, consumer->subdir, usess->path); if (ret < 0) { PERROR("snprintf stream path"); goto error; @@ -178,7 +178,7 @@ error: /* * Sending metadata to the consumer with command ADD_CHANNEL and ADD_STREAM. */ -int ust_consumer_send_metadata(int sock, struct ust_app_session *usess, +static int send_metadata(int sock, struct ust_app_session *usess, struct consumer_output *consumer) { int ret, fd, fds[2]; @@ -225,8 +225,8 @@ int ust_consumer_send_metadata(int sock, struct ust_app_session *usess, /* Get correct path name destination */ if (consumer->type == CONSUMER_DST_LOCAL) { /* Set application path to the destination path */ - ret = snprintf(tmp_path, sizeof(tmp_path), "%s/%s", - consumer->dst.trace_path, usess->path); + ret = snprintf(tmp_path, sizeof(tmp_path), "%s/%s/%s", + consumer->dst.trace_path, consumer->subdir, usess->path); if (ret < 0) { PERROR("snprintf stream path"); goto error; @@ -281,23 +281,27 @@ error: /* * Send all stream fds of the UST session to the consumer. */ -int ust_consumer_send_session(int consumer_fd, struct ust_app_session *usess, - struct consumer_output *consumer) +int ust_consumer_send_session(struct ust_app_session *usess, + struct consumer_output *consumer, struct consumer_socket *sock) { int ret = 0; - int sock = consumer_fd; struct lttng_ht_iter iter; struct ust_app_channel *ua_chan; - DBG("Sending metadata stream fd"); + assert(usess); - if (consumer_fd < 0) { - ERR("Consumer has negative file descriptor"); - return -EINVAL; + if (consumer == NULL || sock == NULL) { + /* There is no consumer so just ignoring the command. */ + DBG("UST consumer does not exist. Not sending streams"); + return 0; } + DBG("Sending metadata stream fd to consumer on %d", sock->fd); + + pthread_mutex_lock(sock->lock); + /* Sending metadata information to the consumer */ - ret = ust_consumer_send_metadata(consumer_fd, usess, consumer); + ret = send_metadata(sock->fd, usess, consumer); if (ret < 0) { goto error; } @@ -314,7 +318,7 @@ int ust_consumer_send_session(int consumer_fd, struct ust_app_session *usess, continue; } - ret = ust_consumer_send_channel_streams(sock, ua_chan, usess, consumer); + ret = send_channel_streams(sock->fd, ua_chan, usess, consumer); if (ret < 0) { rcu_read_unlock(); goto error; @@ -324,8 +328,10 @@ int ust_consumer_send_session(int consumer_fd, struct ust_app_session *usess, DBG("consumer fds (metadata and channel streams) sent"); - return 0; + /* All good! */ + ret = 0; error: + pthread_mutex_unlock(sock->lock); return ret; }