diff mbox series

[02/10] trace-cmd stream: Do not block when stopping threads

Message ID 20230106183930.12565-3-rostedt@goodmis.org (mailing list archive)
State Accepted
Commit 37e96d7855c9638073e93b63992ab468b3a291e9
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 trace-cmd stream is exiting, it flushes the data. But it does so in
a blocking way, where it can block when there's nothing to read. Set the
timeout of trace_stream_read() to zero in order to return immediately.

Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
---
 tracecmd/trace-record.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/tracecmd/trace-record.c b/tracecmd/trace-record.c
index 361524b58772..cc6f27bf22e8 100644
--- a/tracecmd/trace-record.c
+++ b/tracecmd/trace-record.c
@@ -798,7 +798,8 @@  static void stop_threads(enum trace_type type)
 	/* Flush out the pipes */
 	if (type & TRACE_TYPE_STREAM) {
 		do {
-			ret = trace_stream_read(pids, recorder_threads, NULL);
+			struct timeval tv = { 0, 0 };
+			ret = trace_stream_read(pids, recorder_threads, &tv);
 		} while (ret > 0);
 	}
 }