From 4f8ed7002600d92a5bcd12d6e8a4de3b20d31347 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Tue, 26 Feb 2013 14:53:00 -0300 Subject: [PATCH] edactool: don't complain if size is zero. Insted, just sleep for a while Polling time, if read() doesn't block. Currently, trace_pipe_raw never blocks on read(). So, we need to sleep for a while, to avoid spending too much CPU cycles. A fix for it is expected for 3.10. Signed-off-by: Mauro Carvalho Chehab --- edactool.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/edactool.c b/edactool.c index 0462215..15da181 100644 --- a/edactool.c +++ b/edactool.c @@ -34,6 +34,13 @@ #include "kbuffer.h" #include "event-parse.h" +/* + * Polling time, if read() doesn't block. Currently, trace_pipe_raw never + * blocks on read(). So, we need to sleep for a while, to avoid spending + * too much CPU cycles. A fix for it is expected for 3.10. + */ +#define POLLING_TIME 15 + #define PAGE_SIZE 0x400 /* Test for a little-endian machine */ #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ @@ -127,7 +134,11 @@ static int read_ras_event(int fd, struct pevent *pevent, struct kbuffer *kbuf, v kbuffer_next_event(kbuf, NULL); } } else { - printf("read size = 0\n"); + /* + * Before Kernel 3.10, read() never blocks. So, we + * need to sleep for a while + */ + sleep(POLLING_TIME); } } while (1); } -- 2.49.0