X-Git-Url: http://git.lttng.org/?a=blobdiff_plain;f=src%2Fbin%2Flttng-relayd%2Fstream.c;h=f989bfd1361be36bd20d4edfa018f36b11de062b;hb=d49b54aade558422c35ecf9d62a33bf19b80cc51;hp=02bf9dd54995ed2aab6d026ecb578d9127610908;hpb=36d2e35df61339e4394e84ad9790b984d259e0f0;p=lttng-tools.git diff --git a/src/bin/lttng-relayd/stream.c b/src/bin/lttng-relayd/stream.c index 02bf9dd54..f989bfd13 100644 --- a/src/bin/lttng-relayd/stream.c +++ b/src/bin/lttng-relayd/stream.c @@ -17,7 +17,6 @@ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#define _GNU_SOURCE #define _LGPL_SOURCE #include #include @@ -87,7 +86,6 @@ struct relay_stream *stream_create(struct ctf_trace *trace, stream = zmalloc(sizeof(struct relay_stream)); if (stream == NULL) { PERROR("relay stream zmalloc"); - ret = -1; goto error_no_alloc; } @@ -99,6 +97,7 @@ struct relay_stream *stream_create(struct ctf_trace *trace, stream->tracefile_count = tracefile_count; stream->path_name = path_name; stream->channel_name = channel_name; + stream->beacon_ts_end = -1ULL; lttng_ht_node_init_u64(&stream->node, stream->stream_handle); pthread_mutex_init(&stream->lock, NULL); pthread_mutex_init(&stream->reflock, NULL); @@ -307,9 +306,9 @@ static void stream_release(struct urcu_ref *ref) stream_fd_put(stream->stream_fd); stream->stream_fd = NULL; } - if (stream->index_fd) { - stream_fd_put(stream->index_fd); - stream->index_fd = NULL; + if (stream->index_file) { + lttng_index_file_put(stream->index_file); + stream->index_file = NULL; } if (stream->trace) { ctf_trace_put(stream->trace); @@ -346,7 +345,15 @@ void stream_put(struct relay_stream *stream) void try_stream_close(struct relay_stream *stream) { + bool session_aborted; + struct relay_session *session = stream->trace->session; + DBG("Trying to close stream %" PRIu64, stream->stream_handle); + + pthread_mutex_lock(&session->lock); + session_aborted = session->aborted; + pthread_mutex_unlock(&session->lock); + pthread_mutex_lock(&stream->lock); /* * Can be called concurently by connection close and reception of last @@ -388,7 +395,8 @@ void try_stream_close(struct relay_stream *stream) } if (stream->last_net_seq_num != -1ULL && - ((int64_t) (stream->prev_seq - stream->last_net_seq_num)) < 0) { + ((int64_t) (stream->prev_seq - stream->last_net_seq_num)) < 0 + && !session_aborted) { /* * Don't close since we still have data pending. This * handles cases where an explicit close command has @@ -447,6 +455,10 @@ void print_relay_streams(void) struct lttng_ht_iter iter; struct relay_stream *stream; + if (!relay_streams_ht) { + return; + } + rcu_read_lock(); cds_lfht_for_each_entry(relay_streams_ht->ht, &iter.iter, stream, node.node) {