From: Mathieu Desnoyers Date: Thu, 5 Dec 2019 06:58:09 +0000 (-0500) Subject: Fix: lttng-live format: do not error out on empty streams hang up X-Git-Tag: v1.5.8~1 X-Git-Url: http://git.efficios.com/?p=babeltrace.git;a=commitdiff_plain;h=c8fd9d119dc98ef4785b4d7204939a8a259f67e2 Fix: lttng-live format: do not error out on empty streams hang up 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 Signed-off-by: Jérémie Galarneau --- diff --git a/formats/ctf/ctf.c b/formats/ctf/ctf.c index 980ebc9a..1ba9017f 100644 --- a/formats/ctf/ctf.c +++ b/formats/ctf/ctf.c @@ -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.