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>
Thu, 24 Sep 2015 02:23:12 +0000 (22:23 -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 14b30727390832d90740336cafed39520fa9291b..a7455cc710c3fe23864ecea3239f9fbd3a840f19 100644 (file)
@@ -326,17 +326,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);
                }
@@ -910,7 +927,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 03b9ed3ed8bfcdecb184efa81a088539f14284f6..d11e85b2ae7cfd79cab6712abaf50095c93cc3dd 100644 (file)
@@ -331,6 +331,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.027886 seconds and 4 git commands to generate.