diff mbox series

[01/10] trace-cmd library: Set recorder to nonblock when finished

Message ID 20230106183930.12565-2-rostedt@goodmis.org (mailing list archive)
State Accepted
Commit 85f75900c2fb12b4d91dc9e0685cbeec8a9a11c6
Headers show
Series trace-cmd: Fix trace-cmd stream | expand

Commit Message

Steven Rostedt Jan. 6, 2023, 6:39 p.m. UTC
From: "Steven Rostedt (Google)" <rostedt@goodmis.org>

When the recorder is signaled to stop, make sure it only reads in
non-blocking mode.

Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
---
 lib/trace-cmd/trace-recorder.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/lib/trace-cmd/trace-recorder.c b/lib/trace-cmd/trace-recorder.c
index f387091f5177..bb02f7b8ee11 100644
--- a/lib/trace-cmd/trace-recorder.c
+++ b/lib/trace-cmd/trace-recorder.c
@@ -317,11 +317,12 @@  static inline void update_fd(struct tracecmd_recorder *recorder, int size)
  */
 static long read_data(struct tracecmd_recorder *recorder)
 {
+	bool nonblock = recorder->stop;
 	char buf[recorder->subbuf_size];
 	long left;
 	long r, w;
 
-	r = tracefs_cpu_read(recorder->tcpu, buf, false);
+	r = tracefs_cpu_read(recorder->tcpu, buf, nonblock);
 
 	left = r;
 	do {
@@ -344,11 +345,13 @@  static long read_data(struct tracecmd_recorder *recorder)
  */
 static long direct_splice_data(struct tracecmd_recorder *recorder)
 {
-	return tracefs_cpu_pipe(recorder->tcpu, recorder->fd, false);
+	bool nonblock = recorder->stop;
+	return tracefs_cpu_pipe(recorder->tcpu, recorder->fd, nonblock);
 }
 
 static long move_data(struct tracecmd_recorder *recorder)
 {
+	bool nonblock = recorder->stop;
 	long ret;
 
 	if (recorder->flags & TRACECMD_RECORD_NOSPLICE)
@@ -357,7 +360,7 @@  static long move_data(struct tracecmd_recorder *recorder)
 	if (recorder->flags & TRACECMD_RECORD_NOBRASS)
 		return direct_splice_data(recorder);
 
-	ret = tracefs_cpu_write(recorder->tcpu, recorder->fd, false);
+	ret = tracefs_cpu_write(recorder->tcpu, recorder->fd, nonblock);
 	if (ret > 0)
 		update_fd(recorder, ret);
 	return ret;