X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=blobdiff_plain;f=src%2Fbin%2Flttng-relayd%2Fviewer-stream.cpp;fp=src%2Fbin%2Flttng-relayd%2Fviewer-stream.cpp;h=69671bd7af4552ae6eb1803654692265a1c30cd3;hp=ca0be9a62d200136972ac6922a692a6bb5917526;hb=b9973dea9fc1eaf88ef997561878e45cdfd369b4;hpb=b6ae2a9587bfc0f38e3256c869fc822a27e1100c diff --git a/src/bin/lttng-relayd/viewer-stream.cpp b/src/bin/lttng-relayd/viewer-stream.cpp index ca0be9a62..69671bd7a 100644 --- a/src/bin/lttng-relayd/viewer-stream.cpp +++ b/src/bin/lttng-relayd/viewer-stream.cpp @@ -20,9 +20,26 @@ #include "lttng-relayd.h" #include "viewer-stream.h" -static void viewer_stream_destroy(struct relay_viewer_stream *vstream) +static void viewer_stream_release_composite_objects(struct relay_viewer_stream *vstream) { + if (vstream->stream_file.handle) { + fs_handle_close(vstream->stream_file.handle); + vstream->stream_file.handle = NULL; + } + if (vstream->index_file) { + lttng_index_file_put(vstream->index_file); + vstream->index_file = NULL; + } + if (vstream->stream) { + stream_put(vstream->stream); + vstream->stream = NULL; + } lttng_trace_chunk_put(vstream->stream_file.trace_chunk); + vstream->stream_file.trace_chunk = NULL; +} + +static void viewer_stream_destroy(struct relay_viewer_stream *vstream) +{ free(vstream->path_name); free(vstream->channel_name); free(vstream); @@ -198,6 +215,8 @@ struct relay_viewer_stream *viewer_stream_create(struct relay_stream *stream, error: if (vstream) { + /* Not using `put` since vstream is assumed to be published. */ + viewer_stream_release_composite_objects(vstream); viewer_stream_destroy(vstream); } return NULL; @@ -221,23 +240,8 @@ static void viewer_stream_release(struct urcu_ref *ref) if (vstream->stream->is_metadata) { rcu_assign_pointer(vstream->stream->trace->viewer_metadata_stream, NULL); } - viewer_stream_unpublish(vstream); - - if (vstream->stream_file.handle) { - fs_handle_close(vstream->stream_file.handle); - vstream->stream_file.handle = NULL; - } - if (vstream->index_file) { - lttng_index_file_put(vstream->index_file); - vstream->index_file = NULL; - } - if (vstream->stream) { - stream_put(vstream->stream); - vstream->stream = NULL; - } - lttng_trace_chunk_put(vstream->stream_file.trace_chunk); - vstream->stream_file.trace_chunk = NULL; + viewer_stream_release_composite_objects(vstream); call_rcu(&vstream->rcu_node, viewer_stream_destroy_rcu); }