X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=blobdiff_plain;f=src%2Fbin%2Flttng-sessiond%2Fust-consumer.c;h=b7e0d359261dbdec4a686a893dbb3a0416ea04ac;hp=5b909ab1594609257f1026f7d246c39f43bf8d9c;hb=173af62f4804133d4a7f45e34b6f72126f3eca5f;hpb=f64161251bd649abe5b6a473531adfa3af9bd6b6 diff --git a/src/bin/lttng-sessiond/ust-consumer.c b/src/bin/lttng-sessiond/ust-consumer.c index 5b909ab15..b7e0d3592 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) { @@ -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]; @@ -281,23 +281,23 @@ 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); + assert(consumer); + assert(sock); - if (consumer_fd < 0) { - ERR("Consumer has negative file descriptor"); - return -EINVAL; - } + 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 +314,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 +324,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; }