Received: from eggs.gnu.org ([2001:4830:134:3::10]:43545) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YxVcZ-00076q-Og for qemu-devel@nongnu.org; Wed, 27 May 2015 03:19:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YxVcY-0000Pw-5j for qemu-devel@nongnu.org; Wed, 27 May 2015 03:19:23 -0400 From: Fam Zheng Date: Wed, 27 May 2015 15:19:04 +0800 Message-Id: <1432711146-28405-3-git-send-email-famz@redhat.com> In-Reply-To: <1432711146-28405-1-git-send-email-famz@redhat.com> References: <1432711146-28405-1-git-send-email-famz@redhat.com> Subject: [Qemu-devel] [RFC PATCH 2/4] aio-win32: Implement aio_set_io_event_notifier List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Kevin Wolf , qemu-block@nongnu.org, "Michael S. Tsirkin" , Stefan Weil , Stefan Hajnoczi , Paolo Bonzini Signed-off-by: Fam Zheng --- aio-win32.c | 56 +++++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 47 insertions(+), 9 deletions(-) diff --git a/aio-win32.c b/aio-win32.c index 233d8f5..52867ab 100644 --- a/aio-win32.c +++ b/aio-win32.c @@ -27,15 +27,17 @@ struct AioHandler { EventNotifierHandler *io_notify; GPollFD pfd; int deleted; + bool outmost; void *opaque; QLIST_ENTRY(AioHandler) node; }; -void aio_set_fd_handler(AioContext *ctx, - int fd, - IOHandler *io_read, - IOHandler *io_write, - void *opaque) +void aio_set_fd_handler_do(AioContext *ctx, + int fd, + IOHandler *io_read, + IOHandler *io_write, + void *opaque, + bool outmost) { /* fd is a SOCKET in our case */ AioHandler *node; @@ -86,6 +88,7 @@ void aio_set_fd_handler(AioContext *ctx, node->opaque = opaque; node->io_read = io_read; node->io_write = io_write; + node->outmost = outmost; event = event_notifier_get_handle(&ctx->notifier); WSAEventSelect(node->pfd.fd, event, @@ -96,9 +99,29 @@ void aio_set_fd_handler(AioContext *ctx, aio_notify(ctx); } -void aio_set_event_notifier(AioContext *ctx, - EventNotifier *e, - EventNotifierHandler *io_notify) +void aio_set_fd_handler(AioContext *ctx, + int fd, + IOHandler *io_read, + IOHandler *io_write, + void *opaque) +{ + aio_set_fd_handler_do(ctx, fd, io_read, io_write, opaque, false); +} + +void aio_set_iohandler(AioContext *ctx, + int fd, + IOHandler *io_read, + IOHandler *io_write, + void *opaque) +{ + aio_set_fd_handler_do(ctx, fd, io_read, io_write, opaque, true); +} + + +static void aio_set_event_notifier_do(AioContext *ctx, + EventNotifier *e, + EventNotifierHandler *io_notify, + bool outmost) { AioHandler *node; @@ -144,6 +167,20 @@ void aio_set_event_notifier(AioContext *ctx, aio_notify(ctx); } +void aio_set_event_notifier(AioContext *ctx, + EventNotifier *e, + EventNotifierHandler *io_notify) +{ + return aio_set_event_notifier_do(ctx, e, io_notify, false); +} + +void aio_set_io_event_notifier(AioContext *ctx, + EventNotifier *e, + EventNotifierHandler *io_notify) +{ + return aio_set_event_notifier_do(ctx, e, io_notify, true); +} + bool aio_prepare(AioContext *ctx) { static struct timeval tv0; @@ -309,7 +346,8 @@ bool aio_poll(AioContext *ctx, bool blocking) /* fill fd sets */ count = 0; QLIST_FOREACH(node, &ctx->aio_handlers, node) { - if (!node->deleted && node->io_notify) { + if (!node->deleted && node->io_notify && + !(was_dispatching && node->outmost)) { events[count++] = event_notifier_get_handle(node->e); } } -- 2.4.1