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>
Thu, 24 Sep 2015 02:25:49 +0000 (22:25 -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 226ad679ae59936dc5dfeba43148b69d2888ce2f..90d0dbf1c7657973a7e1c0db4d7ca6c909ac1f59 100644 (file)
@@ -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);
index 9507fcaf986a7c4a88994f6570f511f14982cba8..905e245faad068228f2fd74c007818e019ebda23 100644 (file)
@@ -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;
This page took 0.02899 seconds and 4 git commands to generate.