diff options
author | Paolo Bonzini <pbonzini@redhat.com> | 2012-11-23 15:59:43 +0100 |
---|---|---|
committer | Anthony Liguori <aliguori@us.ibm.com> | 2012-11-26 09:37:06 -0600 |
commit | b022b4a44abda9b6f89777b07e538be6f8f7aacb (patch) | |
tree | 930770a31ba76f6071b6f2d79423e2aa76fe2173 /aio-win32.c | |
parent | 21022c92dc5095324ceb3effc068b5ff81642125 (diff) |
aio: avoid livelock behavior for Win32
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>
Diffstat (limited to 'aio-win32.c')
-rw-r--r-- | aio-win32.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/aio-win32.c b/aio-win32.c index a84eb71246..cec4646635 100644 --- a/aio-win32.c +++ b/aio-win32.c @@ -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; |