X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;ds=sidebyside;f=src%2Fbin%2Flttng-relayd%2Fviewer-stream.c;h=2f5d6f788f13ff8a3c35d9aec91ba0e15624a7cc;hb=6c1c0768320135c6936c371b09731851b508c023;hp=a16f331b8f795607389a1efa2c20263ac7609b6f;hpb=2a174661a1e0ab551b41ff1cae7191688525fc1f;p=lttng-tools.git diff --git a/src/bin/lttng-relayd/viewer-stream.c b/src/bin/lttng-relayd/viewer-stream.c index a16f331b8..2f5d6f788 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 @@ -64,10 +65,10 @@ struct relay_viewer_stream *viewer_stream_create(struct relay_stream *stream, vstream->tracefile_count_last = -1ULL; switch (seek_t) { - case VIEWER_SEEK_BEGINNING: + case LTTNG_VIEWER_SEEK_BEGINNING: vstream->tracefile_count_current = stream->oldest_tracefile_id; break; - case VIEWER_SEEK_LAST: + case LTTNG_VIEWER_SEEK_LAST: vstream->tracefile_count_current = stream->tracefile_count_current; break; default: @@ -112,7 +113,7 @@ struct relay_viewer_stream *viewer_stream_create(struct relay_stream *stream, vstream->index_read_fd = read_fd; } - if (seek_t == VIEWER_SEEK_LAST && vstream->index_read_fd >= 0) { + if (seek_t == LTTNG_VIEWER_SEEK_LAST && vstream->index_read_fd >= 0) { off_t lseek_ret; lseek_ret = lseek(vstream->index_read_fd, @@ -196,6 +197,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 +226,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 +260,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) {