[lttng-dev] [LTTNG-TOOLS PATCH] Fix: close indexes when rotating the trace files

Jérémie Galarneau jeremie.galarneau at efficios.com
Fri Nov 27 15:31:45 EST 2015


On Fri, Nov 27, 2015 at 12:12 PM, Julien Desfossez
<jdesfossez at efficios.com> wrote:
> The consumer needs to close the old index file when doing a file
> rotation before opening a new one.
> The relay does not have this problem (handled with refcounts).
>
> Signed-off-by: Julien Desfossez <jdesfossez at efficios.com>
> ---
>  src/common/consumer/consumer.c | 5 +++++
>  1 file changed, 5 insertions(+)
>
> diff --git a/src/common/consumer/consumer.c b/src/common/consumer/consumer.c
> index 2897fb8..5a90c29 100644
> --- a/src/common/consumer/consumer.c
> +++ b/src/common/consumer/consumer.c
> @@ -1779,6 +1779,11 @@ ssize_t lttng_consumer_on_read_subbuffer_splice(
>                         outfd = stream->out_fd;
>
>                         if (stream->index_fd >= 0) {
> +                               ret = close(stream->index_fd);
> +                               if (ret < 0) {
> +                                       PERROR("Closing index");
> +                                       goto end;
> +                               }

Good catch! I'm adding "stream->index_fd = -1;" here to make sure the
index_fd is not closed a second time (on teardown) should the index
file creation fail below.

Thanks!
Jérémie

>                                 ret = index_create_file(stream->chan->pathname,
>                                                 stream->name, stream->uid, stream->gid,
>                                                 stream->chan->tracefile_size,
> --
> 1.9.1
>



-- 
Jérémie Galarneau
EfficiOS Inc.
http://www.efficios.com



More information about the lttng-dev mailing list