From: Julien Desfossez Date: Fri, 15 Nov 2013 01:49:57 +0000 (-0500) Subject: Protect the abort_flag on reset and always close on rotate X-Git-Tag: v2.4.0-rc1~8 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=d1d6606181b5295bd16e481c9fb40a4402e91567;p=lttng-tools.git Protect the abort_flag on reset and always close on rotate Fixes CID 1128897 and a case where the read_fd might not be closed when the abort flag is set. Signed-off-by: Julien Desfossez Signed-off-by: David Goulet --- diff --git a/src/bin/lttng-relayd/live.c b/src/bin/lttng-relayd/live.c index 480c459ce..a2fd09e32 100644 --- a/src/bin/lttng-relayd/live.c +++ b/src/bin/lttng-relayd/live.c @@ -802,26 +802,22 @@ int rotate_viewer_stream(struct relay_viewer_stream *viewer_stream, } viewer_stream->tracefile_count_current = tracefile_id; - if (viewer_stream->abort_flag == 0) { - if (viewer_stream->index_read_fd > 0) { - ret = close(viewer_stream->index_read_fd); - if (ret < 0) { - PERROR("close index file %d", - viewer_stream->index_read_fd); - } - viewer_stream->index_read_fd = -1; - } - if (viewer_stream->read_fd > 0) { - ret = close(viewer_stream->read_fd); - if (ret < 0) { - PERROR("close tracefile %d", - viewer_stream->read_fd); - } - viewer_stream->read_fd = -1; - } - } else { - viewer_stream->abort_flag = 0; + ret = close(viewer_stream->index_read_fd); + if (ret < 0) { + PERROR("close index file %d", + viewer_stream->index_read_fd); + } + viewer_stream->index_read_fd = -1; + ret = close(viewer_stream->read_fd); + if (ret < 0) { + PERROR("close tracefile %d", + viewer_stream->read_fd); } + viewer_stream->read_fd = -1; + + pthread_mutex_lock(&viewer_stream->overwrite_lock); + viewer_stream->abort_flag = 0; + pthread_mutex_unlock(&viewer_stream->overwrite_lock); viewer_stream->index_read_fd = -1; viewer_stream->read_fd = -1;