From d3385eb448e38f828c78f8f68ec5d79c66a58b5d Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Tue, 20 Mar 2012 10:49:19 +0100 Subject: main-loop: interrupt wait when data arrives on a socket Right now, the main loop is not interrupted when data arrives on a socket. To fix this, register each socket to interrupt the main loop with WSAEventSelect. This does not replace select, it only communicates a change in socket state that requires a select call. Since the interrupt fires only once per recv call, or only once after a send call returns EWOULDBLOCK we can activate it on all events unconditionally. If QEMU is momentarily uninterested on some condition, the main loop will not busy wait. Instead, it may get one extra wakeup, but then it will ignore the condition until progress occurs and/or qemu_set_fd_handler is called to set a callback. At this point the condition will be tested via select and the callback will be invoked even if it is still disabled on the event. Signed-off-by: Paolo Bonzini Signed-off-by: Blue Swirl --- oslib-win32.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'oslib-win32.c') diff --git a/oslib-win32.c b/oslib-win32.c index ce3021e..ffbc6d0 100644 --- a/oslib-win32.c +++ b/oslib-win32.c @@ -28,6 +28,7 @@ #include #include "config-host.h" #include "sysemu.h" +#include "main-loop.h" #include "trace.h" #include "qemu_socket.h" @@ -76,6 +77,7 @@ void qemu_vfree(void *ptr) void socket_set_block(int fd) { unsigned long opt = 0; + WSAEventSelect(fd, NULL, 0); ioctlsocket(fd, FIONBIO, &opt); } @@ -83,6 +85,7 @@ void socket_set_nonblock(int fd) { unsigned long opt = 1; ioctlsocket(fd, FIONBIO, &opt); + qemu_fd_register(fd); } int inet_aton(const char *cp, struct in_addr *ia) -- cgit v1.1