Fix: lttng-live format: do not error out on empty streams hang up
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Thu, 5 Dec 2019 06:58:09 +0000 (01:58 -0500)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Fri, 13 Dec 2019 01:02:17 +0000 (20:02 -0500)
Attaching to a stream hung up before providing any trace packet
causes ctf_open_mmap_stream_read() to return an error.

This kind of scenario can happen with the upcoming "lttng clear"
feature.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
formats/ctf/ctf.c

index 980ebc9a9602d47323524194e60752089851134e..1ba9017fdbd5124972bb13ab3fa2c97e4c1b1d68 100644 (file)
@@ -2571,8 +2571,13 @@ int ctf_open_mmap_stream_read(struct ctf_trace *td,
        }
 
        ret = prepare_mmap_stream_definition(td, file_stream, packet_seek);
-       if (ret)
+       if (ret) {
+               /* We need to check for EOF here for empty files. */
+               if (unlikely(file_stream->pos.offset == EOF)) {
+                       ret = 0;
+               }
                goto error_index;
+       }
 
        /*
         * For now, only a single clock per trace is supported.
This page took 0.025408 seconds and 4 git commands to generate.