X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;f=src%2Fbin%2Flttng-relayd%2Fviewer-stream.c;h=37486293f8e8b5df965b2054978cee3aa3b46566;hb=9911d21b154b53ed659415e6baa56d5fb0863716;hp=8ed84a1d118163d7a74c5f2e47b7c9a5a29b0ded;hpb=c4e361a4de07eef209c85d79e734cfb0f94e006d;p=lttng-tools.git diff --git a/src/bin/lttng-relayd/viewer-stream.c b/src/bin/lttng-relayd/viewer-stream.c index 8ed84a1d1..37486293f 100644 --- a/src/bin/lttng-relayd/viewer-stream.c +++ b/src/bin/lttng-relayd/viewer-stream.c @@ -17,6 +17,7 @@ */ #define _GNU_SOURCE +#define _LGPL_SOURCE #include #include @@ -57,8 +58,16 @@ struct relay_viewer_stream *viewer_stream_create(struct relay_stream *stream, vstream->session_id = stream->session_id; vstream->stream_handle = stream->stream_handle; vstream->path_name = strndup(stream->path_name, LTTNG_VIEWER_PATH_MAX); + if (vstream->path_name == NULL) { + PERROR("relay viewer path_name alloc"); + goto error; + } vstream->channel_name = strndup(stream->channel_name, LTTNG_VIEWER_NAME_MAX); + if (vstream->channel_name == NULL) { + PERROR("relay viewer channel_name alloc"); + goto error; + } vstream->tracefile_count = stream->tracefile_count; vstream->metadata_flag = stream->metadata_flag; vstream->tracefile_count_last = -1ULL; @@ -196,6 +205,7 @@ end: /* * Rotate a stream to the next tracefile. * + * Must be called with viewer_stream_rotation_lock held. * Returns 0 on success, 1 on EOF, a negative value on error. */ int viewer_stream_rotate(struct relay_viewer_stream *vstream, @@ -224,12 +234,6 @@ int viewer_stream_rotate(struct relay_viewer_stream *vstream, goto end; } - /* - * Lock to execute rotation in order to avoid races between a modification - * on the index values. - */ - pthread_mutex_lock(&stream->viewer_stream_rotation_lock); - /* * The writer and the reader are not working in the same tracefile, we can * read up to EOF, we don't care about the total_index_received. @@ -264,8 +268,6 @@ int viewer_stream_rotate(struct relay_viewer_stream *vstream, vstream->abort_flag = 0; pthread_mutex_unlock(&vstream->overwrite_lock); - pthread_mutex_unlock(&stream->viewer_stream_rotation_lock); - ret = index_open(vstream->path_name, vstream->channel_name, vstream->tracefile_count, vstream->tracefile_count_current); if (ret < 0) {