[Spice-devel] [PATCH spice] reds: increase listening socket backlog

Marc-André Lureau marcandre.lureau at gmail.com
Wed Jan 21 07:46:07 PST 2015


With TCP socket, the backlog doesn't seem to be such an important value,
perhaps because of latency or underlying protocol behaviour. However,
on UNIX socket, it is fairly easy to reach the backlog limit and the
client will get an EAGAIN error (not ECONNREFUSED as stated in
listen(7)) that is not easy to deal with: attempting to reconnect in a
loop might busy-loop forever as there are no guarantee the server will
accept new connections, so it will be inherently racy.

Typically, Spice server can easily have up to 15 concurrent incoming
connections that are established during initialization of the session,
so let's raise the backlog limit to the default system value, which is
128 on Linux to avoid any guesses.
---
 server/reds.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/server/reds.c b/server/reds.c
index b9030c0..b4053f5 100644
--- a/server/reds.c
+++ b/server/reds.c
@@ -2424,7 +2424,7 @@ static int reds_init_socket(const char *addr, int portnr, int family)
     return -1;
 
 listen:
-    if (listen(slisten,1) != 0) {
+    if (listen(slisten, SOMAXCONN) != 0) {
         spice_warning("listen: %s", strerror(errno));
         close(slisten);
         return -1;
-- 
2.1.0



More information about the Spice-devel mailing list