Fix: ask new streams HUP
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Tue, 25 Aug 2015 13:00:50 +0000 (09:00 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Fri, 4 Sep 2015 22:43:42 +0000 (18:43 -0400)
Test closed streams for content to check for HUP.

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/stream.c

index c41659ac5b178d865a73d501e7156477b18a0fc0..096c855f6d91eda1110a2382b9cfbe81d42f3ca3 100644 (file)
@@ -327,17 +327,34 @@ int make_viewer_streams(struct relay_session *session,
                                        /* Update number of created stream counter. */
                                        (*nb_created)++;
                                }
+                               /*
+                                * Ensure a self-reference is preserved even
+                                * after we have put our local reference.
+                                */
+                               viewer_stream_get(vstream);
                        } else {
                                if (!vstream->sent_flag && nb_unsent) {
                                        /* Update number of unsent stream counter. */
                                        (*nb_unsent)++;
                                }
-                               viewer_stream_put(vstream);
                        }
                        /* Update number of total stream counter. */
                        if (nb_total) {
-                               (*nb_total)++;
+                               if (stream->is_metadata) {
+                                       if (!stream->closed ||
+                                                       stream->metadata_received > vstream->metadata_sent) {
+                                               (*nb_total)++;
+                                       }
+                               } else {
+                                       if (!stream->closed ||
+                                               !(((int64_t) (stream->prev_seq - stream->last_net_seq_num)) >= 0)) {
+
+                                               (*nb_total)++;
+                                       }
+                               }
                        }
+                       /* Put local reference. */
+                       viewer_stream_put(vstream);
                next:
                        stream_put(stream);
                }
@@ -911,7 +928,8 @@ int viewer_get_new_streams(struct relay_connection *conn)
        response.streams_count = htobe32(nb_streams);
 
        /*
-        * If the session is closed, HUP when there are no more streams.
+        * If the session is closed, HUP when there are no more streams
+        * with data.
         */
        if (closed && nb_total == 0) {
                send_streams = 0;
index af4ef1bbb80d9e17fe331298c4fac558d0795d3c..3f76b1e6a63cb6093eafb443689f087d2805fdb1 100644 (file)
@@ -332,6 +332,7 @@ void stream_close(struct relay_stream *stream)
 {
        DBG("closing stream %" PRIu64, stream->stream_handle);
        pthread_mutex_lock(&stream->lock);
+       stream->closed = true;
        relay_index_close_all(stream);
        pthread_mutex_unlock(&stream->lock);
        stream_put(stream);
This page took 0.035693 seconds and 4 git commands to generate.