From: Mathieu Desnoyers Date: Tue, 25 Aug 2015 13:00:50 +0000 (-0400) Subject: Fix: ask new streams HUP X-Git-Tag: v2.6.1~35 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=64bda0b4a1f90d2df40bc4b4b2c962876297ea9c;p=lttng-tools.git Fix: ask new streams HUP Test closed streams for content to check for HUP. 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 14b307273..a7455cc71 100644 --- a/src/bin/lttng-relayd/live.c +++ b/src/bin/lttng-relayd/live.c @@ -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; diff --git a/src/bin/lttng-relayd/stream.c b/src/bin/lttng-relayd/stream.c index 03b9ed3ed..d11e85b2a 100644 --- a/src/bin/lttng-relayd/stream.c +++ b/src/bin/lttng-relayd/stream.c @@ -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);