From mboxrd@z Thu Jan 1 00:00:00 1970 From: Mathieu Desnoyers Subject: [PATCH babeltrace-1.5 6/6] Fix: lttng-live format: do not error out on empty streams hang up Date: Thu, 5 Dec 2019 01:58:09 -0500 Message-ID: <20191205065809.16728-7-mathieu.desnoyers__23563.4265862004$1575529305$gmane$org@efficios.com> References: <20191205065809.16728-1-mathieu.desnoyers@efficios.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail.efficios.com (mail.efficios.com [IPv6:2607:5300:60:7898::beef]) by lists.lttng.org (Postfix) with ESMTPS id 47T64S400Tz10hJ for ; Thu, 5 Dec 2019 01:58:16 -0500 (EST) In-Reply-To: <20191205065809.16728-1-mathieu.desnoyers@efficios.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: lttng-dev-bounces@lists.lttng.org Sender: "lttng-dev" To: jgalar@efficios.com Cc: lttng-dev@lists.lttng.org List-Id: lttng-dev@lists.lttng.org 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 --- formats/ctf/ctf.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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. -- 2.17.1