[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH 1.3] aio: avoid livelock behavior for Win32
From: |
Anthony Liguori |
Subject: |
Re: [Qemu-devel] [PATCH 1.3] aio: avoid livelock behavior for Win32 |
Date: |
Mon, 26 Nov 2012 15:49:12 -0600 |
User-agent: |
Notmuch/0.13.2+93~ged93d79 (http://notmuchmail.org) Emacs/23.3.1 (x86_64-pc-linux-gnu) |
Paolo Bonzini <address@hidden> writes:
> 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 <address@hidden>
> ---
> Found by the new unit tests.
Applied. Thanks.
Regards,
Anthony Liguori
>
> aio-win32.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/aio-win32.c b/aio-win32.c
> index a84eb71..cec4646 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;
> --
> 1.8.0