]> git.proxmox.com Git - qemu.git/commitdiff
aio: avoid livelock behavior for Win32
authorPaolo Bonzini <pbonzini@redhat.com>
Fri, 23 Nov 2012 14:59:43 +0000 (15:59 +0100)
committerAnthony Liguori <aliguori@us.ibm.com>
Mon, 26 Nov 2012 15:37:06 +0000 (09:37 -0600)
The repeated calls to WaitForMultipleObjects may cause a livelock in aio_poll,
where no progress is made on bottom halves.  This patch matches the behavior
of the POSIX code.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
aio-win32.c

index a84eb712460df2463ac859865272d319db45c63a..cec4646635b7dd2900d408ac2975a8b78be20612 100644 (file)
@@ -173,7 +173,7 @@ bool aio_poll(AioContext *ctx, bool blocking)
     }
 
     /* wait until next event */
-    for (;;) {
+    while (count > 0) {
         int timeout = blocking ? INFINITE : 0;
         int ret = WaitForMultipleObjects(count, events, FALSE, timeout);
 
@@ -209,6 +209,9 @@ bool aio_poll(AioContext *ctx, bool blocking)
                 g_free(tmp);
             }
         }
+
+        /* Try again, but only call each handler once.  */
+        events[ret - WAIT_OBJECT_0] = events[--count];
     }
 
     return progress;