]> git.proxmox.com Git - qemu.git/blobdiff - block-raw-posix.c
adlib.c includes fmopl.h and so needs -DBUILD_Y8950=0 too
[qemu.git] / block-raw-posix.c
index 74a9f5207119399f2cae1c9758f3b55f253bd27c..0a06a12fb6d6fea94f7c5ee5759c9a4fd545fa4f 100644 (file)
@@ -75,7 +75,7 @@
 
 /* OS X does not have O_DSYNC */
 #ifndef O_DSYNC
-#define O_SYNC
+#define O_DSYNC O_SYNC
 #endif
 
 /* Approximate O_DIRECT with O_DSYNC if O_DIRECT isn't available */
@@ -497,15 +497,17 @@ static void posix_aio_read(void *opaque)
     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 @@ static int posix_aio_init(void)
     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);