Sometimes sorecvfrom() is called from slirp.c because revents == G_IO_IN, however inside sorecvfrom() function, ioctlsocket() returns 0 bytes available and recvfrom could be blocking indefinitely. This adds a non-blocking flag to recvfrom and checks data availability. --- slirp/socket.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/slirp/socket.c b/slirp/socket.c index c01d8696af..ea30478ce6 100644 --- a/slirp/socket.c +++ b/slirp/socket.c @@ -581,7 +581,7 @@ sorecvfrom(struct socket *so) } /* } */ - m->m_len = recvfrom(so->s, m->m_data, len, 0, + m->m_len = recvfrom(so->s, m->m_data, len, MSG_DONTWAIT, (struct sockaddr *)&addr, &addrlen); DEBUG_MISC((dfd, " did recvfrom %d, errno = %d-%s\n", m->m_len, errno,strerror(errno))); @@ -618,6 +618,8 @@ sorecvfrom(struct socket *so) break; } m_free(m); + } else if (m->m_len==0) { + m_free(m); } else { /* * Hack: domain name lookup will be used the most for UDP, -- 2.20.1