diff mbox series

[1/2] libtracefs: Do not return negative on EAGAIN for tracefs_cpu_flush_write()

Message ID 20221110225959.2285998-2-rostedt@goodmis.org (mailing list archive)
State Accepted
Commit 1388ed664739b89e0221e25696b525c527c560a6
Headers show
Series libtracefs: Handle EAGAIN case in flush functions | expand

Commit Message

Steven Rostedt Nov. 10, 2022, 10:59 p.m. UTC
From: "Steven Rostedt (Google)" <rostedt@goodmis.org>

Like tracefs_cpu_flush(), when the buffer is empty, and because the
reading of the buffer is done in NON_BLOCK mode, it will finish with a
negative and EAGAIN. This is a successful state, do not return a negative
number here.

Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
---
 src/tracefs-record.c | 4 ++++
 1 file changed, 4 insertions(+)
diff mbox series

Patch

diff --git a/src/tracefs-record.c b/src/tracefs-record.c
index dbe0e9f01aad..71d1df99bb02 100644
--- a/src/tracefs-record.c
+++ b/src/tracefs-record.c
@@ -495,6 +495,10 @@  int tracefs_cpu_flush_write(struct tracefs_cpu *tcpu, int wfd)
 	if (ret > 0)
 		ret = write(wfd, buffer, ret);
 
+	/* It's OK if there's no data to read */
+	if (ret < 0 && errno == EAGAIN)
+		ret = 0;
+
 	return ret;
 }