From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:55226) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Td6YP-00085R-De for qemu-devel@nongnu.org; Mon, 26 Nov 2012 16:49:26 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Td6YO-0003oj-Eg for qemu-devel@nongnu.org; Mon, 26 Nov 2012 16:49:25 -0500 Received: from e28smtp04.in.ibm.com ([122.248.162.4]:36123) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Td6YN-0003oO-RQ for qemu-devel@nongnu.org; Mon, 26 Nov 2012 16:49:24 -0500 Received: from /spool/local by e28smtp04.in.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 27 Nov 2012 03:19:21 +0530 Received: from d28av04.in.ibm.com (d28av04.in.ibm.com [9.184.220.66]) by d28relay03.in.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id qAQLnH8M40239224 for ; Tue, 27 Nov 2012 03:19:17 +0530 Received: from d28av04.in.ibm.com (loopback [127.0.0.1]) by d28av04.in.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id qAR3J8Ho000425 for ; Tue, 27 Nov 2012 14:19:09 +1100 From: Anthony Liguori In-Reply-To: <1353682783-25624-1-git-send-email-pbonzini@redhat.com> References: <1353682783-25624-1-git-send-email-pbonzini@redhat.com> Date: Mon, 26 Nov 2012 15:49:12 -0600 Message-ID: <87mwy4rq5j.fsf@codemonkey.ws> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Subject: Re: [Qemu-devel] [PATCH 1.3] aio: avoid livelock behavior for Win32 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini , qemu-devel@nongnu.org Paolo Bonzini 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 > --- > 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