Received: from eggs.gnu.org ([2001:4830:134:3::10]:46700) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X4oZH-0005Ps-4q for qemu-devel@nongnu.org; Wed, 09 Jul 2014 05:53:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1X4oZ8-00011Z-5A for qemu-devel@nongnu.org; Wed, 09 Jul 2014 05:53:39 -0400 Received: from mail-qa0-x22d.google.com ([2607:f8b0:400d:c00::22d]:48954) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X4oZ8-00011S-17 for qemu-devel@nongnu.org; Wed, 09 Jul 2014 05:53:30 -0400 Received: by mail-qa0-f45.google.com with SMTP id s7so1861143qap.4 for ; Wed, 09 Jul 2014 02:53:29 -0700 (PDT) Received: from yakj.usersys.redhat.com (net-2-35-201-190.cust.vodafonedsl.it. [2.35.201.190]) by mx.google.com with ESMTPSA id j97sm31669122qgd.37.2014.07.09.02.53.27 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 09 Jul 2014 02:53:28 -0700 (PDT) Sender: Paolo Bonzini From: Paolo Bonzini Date: Wed, 9 Jul 2014 11:53:04 +0200 Message-Id: <1404899590-24973-5-git-send-email-pbonzini@redhat.com> In-Reply-To: <1404899590-24973-1-git-send-email-pbonzini@redhat.com> References: <1404899590-24973-1-git-send-email-pbonzini@redhat.com> Subject: [Qemu-devel] [PATCH 04/10] AioContext: run bottom halves after polling List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Make the dispatching phase the same before blocking and afterwards. The next patch will make aio_dispatch public and use it directly for the GSource case, instead of aio_poll. aio_poll can then be simplified heavily. Signed-off-by: Paolo Bonzini --- aio-posix.c | 4 ++++ aio-win32.c | 8 +++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/aio-posix.c b/aio-posix.c index 55706f8..798a3ff 100644 --- a/aio-posix.c +++ b/aio-posix.c @@ -264,6 +264,10 @@ bool aio_poll(AioContext *ctx, bool blocking) /* Run dispatch even if there were no readable fds to run timers */ aio_set_dispatching(ctx, true); + if (aio_bh_poll(ctx)) { + progress = true; + } + if (aio_dispatch(ctx)) { progress = true; } diff --git a/aio-win32.c b/aio-win32.c index 5e37b42..2ac38a8 100644 --- a/aio-win32.c +++ b/aio-win32.c @@ -143,7 +143,7 @@ bool aio_poll(AioContext *ctx, bool blocking) { AioHandler *node; HANDLE events[MAXIMUM_WAIT_OBJECTS + 1]; - bool progress; + bool progress, first; int count; int timeout; @@ -177,6 +177,7 @@ bool aio_poll(AioContext *ctx, bool blocking) } ctx->walking_handlers--; + first = true; /* wait until next event */ while (count > 0) { @@ -186,6 +187,11 @@ bool aio_poll(AioContext *ctx, bool blocking) ? qemu_timeout_ns_to_ms(aio_compute_timeout(ctx)) : 0; ret = WaitForMultipleObjects(count, events, FALSE, timeout); + if (first && aio_bh_poll(ctx)) { + progress = true; + } + first = false; + /* if we have any signaled events, dispatch event */ if ((DWORD) (ret - WAIT_OBJECT_0) >= count) { break; -- 1.9.3