]> www.infradead.org Git - users/mchehab/edactool.git/commitdiff
edactool: don't complain if size is zero. Insted, just sleep for a while
authorMauro Carvalho Chehab <mchehab@redhat.com>
Tue, 26 Feb 2013 17:53:00 +0000 (14:53 -0300)
committerMauro Carvalho Chehab <mchehab@redhat.com>
Tue, 26 Feb 2013 19:04:11 +0000 (16:04 -0300)
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 <mchehab@redhat.com>
edactool.c

index 046221566cd2a9e2362a758339c10d52f5b6259c..15da181f5807f14467c5f1f8e0e88f1877dd8b2a 100644 (file)
 #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);
 }