[PATCH] trace-cmd: Do not block on reads when record is finished

From: Steven Rostedt (Red Hat)
Date: Thu Feb 28 2013 - 11:29:43 EST


Starting with Linux v3.10, trace_pipe_raw will block on reads.
We need to make sure that when the trace is done, the reads do
not block, and flushing finishes reading the ring buffer.

Signed-off-by: Steven Rostedt <rostedt@xxxxxxxxxxx>
---
trace-recorder.c | 6 ++++++
1 file changed, 6 insertions(+)

diff --git a/trace-recorder.c b/trace-recorder.c
index 1b9723d..4e15b86 100644
--- a/trace-recorder.c
+++ b/trace-recorder.c
@@ -249,9 +249,15 @@ int tracecmd_start_recording(struct tracecmd_recorder *recorder, unsigned long s

void tracecmd_stop_recording(struct tracecmd_recorder *recorder)
{
+ long flags;
+
if (!recorder)
return;

+ /* Do not block on reads for flushing */
+ flags = fcntl(recorder->trace_fd, F_GETFL);
+ fcntl(recorder->trace_fd, F_SETFL, flags | O_NONBLOCK);
+
recorder->stop = 1;
}

--
1.7.10.4



--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/