Hi,

I am having a guest freeze issue (win10), and through debugging I found out
that 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. I am not sure
the root cause of the situation, but I added a non-blocking check to
recvfrom and it fixed my issue. My patch is as attached. Please check if
this is a right fix.
From 11dfa3402eacac9a05f12934fd322f37c8e0ce37 Mon Sep 17 00:00:00 2001
From: Vic Lee <llyzs....@gmail.com>
Date: Thu, 28 Feb 2019 18:23:24 +0800
Subject: [PATCH] socket: fix blocking udp recvfrom.

---
 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

Reply via email to