Received: from eggs.gnu.org ([208.118.235.92]:51691) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ud0E4-0001Ib-T9 for qemu-devel@nongnu.org; Thu, 16 May 2013 11:36:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Ud0E1-0003Jl-T6 for qemu-devel@nongnu.org; Thu, 16 May 2013 11:36:16 -0400 Received: from mx1.redhat.com ([209.132.183.28]:63767) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ud0E1-0003Jf-Kc for qemu-devel@nongnu.org; Thu, 16 May 2013 11:36:13 -0400 From: Stefan Hajnoczi Date: Thu, 16 May 2013 17:36:00 +0200 Message-Id: <1368718561-7816-2-git-send-email-stefanha@redhat.com> In-Reply-To: <1368718561-7816-1-git-send-email-stefanha@redhat.com> References: <1368718561-7816-1-git-send-email-stefanha@redhat.com> Subject: [Qemu-devel] [PATCH for-1.5 1/2] main-loop: narrow win32 pollfds_fill() event bitmasks List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Paolo Bonzini , Anthony Liguori , therock247uk@247fixes.com, Stefan Hajnoczi , geleman@gmail.com pollfds_fill() and pollfds_poll() translate GPollFD to rfds/wfds/xfds for sockets on win32. select(2) is the underlying system call which is used to monitor sockets for activity. Currently file descriptors that monitor G_IO_ERR will be included in both rfds and wfds. As a result, select(2) will report writability on file descriptors where we only really wanted to monitor readability (with errors). slirp_pollfds_poll() hit this issue: UDP sockets are blocking sockets so we hang in sorecvfrom() when G_IO_ERR is set due to the socket being writable (we only wanted to check for readability). This patch fixes the slirp_pollfds_poll() hang. Signed-off-by: Stefan Hajnoczi --- main-loop.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/main-loop.c b/main-loop.c index f46aece..2b8eed7 100644 --- a/main-loop.c +++ b/main-loop.c @@ -333,11 +333,11 @@ static int pollfds_fill(GArray *pollfds, fd_set *rfds, fd_set *wfds, GPollFD *pfd = &g_array_index(pollfds, GPollFD, i); int fd = pfd->fd; int events = pfd->events; - if (events & (G_IO_IN | G_IO_HUP | G_IO_ERR)) { + if (events & G_IO_IN) { FD_SET(fd, rfds); nfds = MAX(nfds, fd); } - if (events & (G_IO_OUT | G_IO_ERR)) { + if (events & G_IO_OUT) { FD_SET(fd, wfds); nfds = MAX(nfds, fd); } @@ -360,10 +360,10 @@ static void pollfds_poll(GArray *pollfds, int nfds, fd_set *rfds, int revents = 0; if (FD_ISSET(fd, rfds)) { - revents |= G_IO_IN | G_IO_HUP | G_IO_ERR; + revents |= G_IO_IN; } if (FD_ISSET(fd, wfds)) { - revents |= G_IO_OUT | G_IO_ERR; + revents |= G_IO_OUT; } if (FD_ISSET(fd, xfds)) { revents |= G_IO_PRI; -- 1.8.1.4