From: Julien Desfossez Date: Wed, 15 Jan 2014 16:29:36 +0000 (-0500) Subject: Fix: send the streams sent message after metadata X-Git-Tag: v2.5.0-rc1~219 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=601262d65a9ccd90198558639ef2a73cda4230e1;p=lttng-tools.git Fix: send the streams sent message after metadata We now make sure that we only sent the streams_sent message to the relay when all the streams (including the metadata) are sent. Signed-off-by: Julien Desfossez Signed-off-by: David Goulet --- diff --git a/src/bin/lttng-relayd/main.c b/src/bin/lttng-relayd/main.c index fe4a898bc..d8105e405 100644 --- a/src/bin/lttng-relayd/main.c +++ b/src/bin/lttng-relayd/main.c @@ -1350,11 +1350,7 @@ int relay_add_stream(struct lttcomm_relayd_hdr *recv_hdr, * stream message is received, this list is emptied and streams are set * with the viewer ready flag. */ - if (stream->metadata_flag) { - stream->viewer_ready = 1; - } else { - queue_stream_handle(stream->stream_handle, cmd); - } + queue_stream_handle(stream->stream_handle, cmd); lttng_ht_node_init_ulong(&stream->stream_n, (unsigned long) stream->stream_handle); diff --git a/src/bin/lttng-sessiond/kernel-consumer.c b/src/bin/lttng-sessiond/kernel-consumer.c index 4c069588a..415361274 100644 --- a/src/bin/lttng-sessiond/kernel-consumer.c +++ b/src/bin/lttng-sessiond/kernel-consumer.c @@ -305,7 +305,6 @@ int kernel_consumer_send_channel_stream(struct consumer_socket *sock, { int ret; struct ltt_kernel_stream *stream; - uint64_t channel_key = -1ULL; /* Safety net */ assert(channel); @@ -339,22 +338,8 @@ int kernel_consumer_send_channel_stream(struct consumer_socket *sock, if (ret < 0) { goto error; } - if (channel_key == -1ULL) { - channel_key = channel->fd; - } - } - - if (!monitor || channel_key == -1ULL) { - goto end; - } - - /* Add stream on the kernel consumer side. */ - ret = kernel_consumer_streams_sent(sock, session, channel_key); - if (ret < 0) { - goto error; } -end: error: return ret; } @@ -403,6 +388,16 @@ int kernel_consumer_send_session(struct consumer_socket *sock, if (ret < 0) { goto error; } + if (monitor) { + /* + * Inform the relay that all the streams for the + * channel were sent. + */ + ret = kernel_consumer_streams_sent(sock, session, chan->fd); + if (ret < 0) { + goto error; + } + } } DBG("Kernel consumer FDs of metadata and channel streams sent"); diff --git a/src/common/kernel-consumer/kernel-consumer.c b/src/common/kernel-consumer/kernel-consumer.c index c95355e9a..0b793c903 100644 --- a/src/common/kernel-consumer/kernel-consumer.c +++ b/src/common/kernel-consumer/kernel-consumer.c @@ -176,10 +176,12 @@ int lttng_kconsumer_snapshot_channel(uint64_t key, char *path, DBG("Kernel consumer snapshot stream %s/%s (%" PRIu64 ")", path, stream->name, stream->key); } - ret = consumer_send_relayd_streams_sent(relayd_id); - if (ret < 0) { - ERR("sending streams sent to relayd"); - goto end_unlock; + if (relayd_id != -1ULL) { + ret = consumer_send_relayd_streams_sent(relayd_id); + if (ret < 0) { + ERR("sending streams sent to relayd"); + goto end_unlock; + } } ret = kernctl_buffer_flush(stream->wait_fd); diff --git a/src/common/ust-consumer/ust-consumer.c b/src/common/ust-consumer/ust-consumer.c index af3aca0a5..bdabb5e49 100644 --- a/src/common/ust-consumer/ust-consumer.c +++ b/src/common/ust-consumer/ust-consumer.c @@ -438,17 +438,6 @@ static int send_sessiond_channel(int sock, net_seq_idx = stream->net_seq_idx; } } - ret = consumer_send_relayd_streams_sent(net_seq_idx); - if (ret < 0) { - /* - * Flag that the relayd was the problem here probably due to a - * communicaton error on the socket. - */ - if (relayd_error) { - *relayd_error = 1; - } - ret_code = LTTNG_ERR_RELAYD_CONNECT_FAIL; - } } /* Inform sessiond that we are about to send channel and streams. */ @@ -769,6 +758,12 @@ static int setup_metadata(struct lttng_consumer_local_data *ctx, uint64_t key) ret = LTTCOMM_CONSUMERD_ERROR_METADATA; goto error; } + ret = consumer_send_relayd_streams_sent( + metadata->metadata_stream->net_seq_idx); + if (ret < 0) { + ret = LTTCOMM_CONSUMERD_RELAYD_FAIL; + goto error; + } } ret = send_streams_to_thread(metadata, ctx);