Fix: don't expose empty streams
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Tue, 25 Aug 2015 18:49:34 +0000 (14:49 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Fri, 4 Sep 2015 22:43:42 +0000 (18:43 -0400)
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
src/bin/lttng-relayd/live.c
src/bin/lttng-relayd/main.c

index 2972a500f13f860f21b7e8422bdcbc2e0dd17c31..aa0586814e6ba55adeb6c2b35d5c31f1789bcc51 100644 (file)
@@ -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);
index 057ac4046c01e67ae05fa938db49e89c9c913718..adb044f1d3ebd4b6b6d58a035c6e4d9eece706b9 100644 (file)
@@ -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:
This page took 0.028267 seconds and 4 git commands to generate.