From: Mathieu Desnoyers Date: Tue, 25 Aug 2015 18:49:34 +0000 (-0400) Subject: Fix: don't expose empty streams X-Git-Tag: v2.7.0-rc2~87 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=1b95be80706a2f046cf526825b9da1f87a94b1ec;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 2972a500f..aa0586814 100644 --- a/src/bin/lttng-relayd/live.c +++ b/src/bin/lttng-relayd/live.c @@ -313,6 +313,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 057ac4046..adb044f1d 100644 --- a/src/bin/lttng-relayd/main.c +++ b/src/bin/lttng-relayd/main.c @@ -2146,6 +2146,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); @@ -2269,10 +2270,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: