qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [5716] block: make raw aio signaling non-blocking (Gerd Hof


From: Anthony Liguori
Subject: [Qemu-devel] [5716] block: make raw aio signaling non-blocking (Gerd Hoffman)
Date: Thu, 13 Nov 2008 19:23:18 +0000

Revision: 5716
          http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=5716
Author:   aliguori
Date:     2008-11-13 19:23:17 +0000 (Thu, 13 Nov 2008)

Log Message:
-----------
block: make raw aio signaling non-blocking (Gerd Hoffman)

This patch switches the read handle of the signaling pipe into
non-blocking mode.  This avoids unwanted blocking reads and also
allows to read all bytes out of the signaling pipe in case we got
signaled more that once before the handler ran.

Signed-off-by: Gerd Hoffmann <address@hidden>
Signed-off-by: Anthony Liguori <address@hidden>

Modified Paths:
--------------
    trunk/block-raw-posix.c

Modified: trunk/block-raw-posix.c
===================================================================
--- trunk/block-raw-posix.c     2008-11-13 19:21:00 UTC (rev 5715)
+++ trunk/block-raw-posix.c     2008-11-13 19:23:17 UTC (rev 5716)
@@ -497,15 +497,17 @@
     int ret;
     ssize_t len;
 
-    do {
-        char byte;
+    /* read all bytes from signal pipe */
+    for (;;) {
+        char bytes[16];
 
-        len = read(s->rfd, &byte, 1);
+        len = read(s->rfd, bytes, sizeof(bytes));
         if (len == -1 && errno == EINTR)
-            continue;
-        if (len == -1 && errno == EAGAIN)
-            break;
-    } while (len == -1);
+            continue; /* try again */
+        if (len == sizeof(bytes))
+            continue; /* more to read */
+        break;
+    }
 
     for(;;) {
         pacb = &s->first_aio;
@@ -591,6 +593,7 @@
     s->rfd = fds[0];
     s->wfd = fds[1];
 
+    fcntl(s->rfd, F_SETFL, O_NONBLOCK);
     fcntl(s->wfd, F_SETFL, O_NONBLOCK);
 
     qemu_aio_set_fd_handler(s->rfd, posix_aio_read, NULL, posix_aio_flush, s);






reply via email to

[Prev in Thread] Current Thread [Next in Thread]