From: Mathieu Desnoyers Date: Tue, 25 Aug 2015 18:49:34 +0000 (-0400) Subject: Fix: don't expose empty streams X-Git-Tag: v2.6.1~32 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=b8ee61ff06b128ff98f97bc45097ee8e582537ee;p=lttng-tools.git Fix: don't expose empty streams Signed-off-by: Mathieu Desnoyers Signed-off-by: Jérémie Galarneau --- diff --git a/src/bin/lttng-relayd/live.c b/src/bin/lttng-relayd/live.c index 226ad679a..90d0dbf1c 100644 --- a/src/bin/lttng-relayd/live.c +++ b/src/bin/lttng-relayd/live.c @@ -312,6 +312,12 @@ int make_viewer_streams(struct relay_session *session, if (!stream->published) { goto next; } + /* + * Stream has no data, don't consider it yet. + */ + if (stream->prev_seq == -1ULL) { + goto next; + } vstream = viewer_stream_get_by_id(stream->stream_handle); if (!vstream) { vstream = viewer_stream_create(stream, seek_t); diff --git a/src/bin/lttng-relayd/main.c b/src/bin/lttng-relayd/main.c index 9507fcaf9..905e245fa 100644 --- a/src/bin/lttng-relayd/main.c +++ b/src/bin/lttng-relayd/main.c @@ -2114,6 +2114,7 @@ static int relay_process_data(struct relay_connection *conn) uint64_t net_seq_num; uint32_t data_size; struct relay_session *session; + bool new_stream = false; ret = conn->sock->ops->recvmsg(conn->sock, &data_hdr, sizeof(struct lttcomm_relayd_data_hdr), 0); @@ -2237,10 +2238,19 @@ static int relay_process_data(struct relay_connection *conn) } stream->tracefile_size_current += data_size + be32toh(data_hdr.padding_size); + if (stream->prev_seq == -1ULL) { + new_stream = true; + } + stream->prev_seq = net_seq_num; end_stream_unlock: pthread_mutex_unlock(&stream->lock); + if (new_stream) { + pthread_mutex_lock(&session->lock); + uatomic_set(&session->new_streams, 1); + pthread_mutex_unlock(&session->lock); + } end_stream_put: stream_put(stream); end: @@ -2292,7 +2302,6 @@ static void *relay_thread_worker(void *data) { int ret, err = -1, last_seen_data_fd = -1; uint32_t nb_fd; - struct relay_connection *conn; struct lttng_poll_event events; struct lttng_ht *relay_connections_ht; struct lttng_ht_iter iter;