From: Erik Dubbelboer Date: Wed, 11 Apr 2012 15:04:31 +0000 (+0200) Subject: added explanation for the magic 511 backlog number X-Git-Url: https://git.saurik.com/redis.git/commitdiff_plain/b9cd703b5b16e350c0783061ce99c79089bcfc0a?ds=sidebyside added explanation for the magic 511 backlog number --- diff --git a/src/anet.c b/src/anet.c index ba4e6cce..434d945c 100644 --- a/src/anet.c +++ b/src/anet.c @@ -262,7 +262,11 @@ static int anetListen(char *err, int s, struct sockaddr *sa, socklen_t len) { close(s); return ANET_ERR; } - if (listen(s, 511) == -1) { /* the magic 511 constant is from nginx */ + + /* Use a backlog of 512 entries. We pass 511 to the listen() call because + * the kernel does: backlogsize = roundup_pow_of_two(backlogsize + 1); + * which will thus give us a backlog of 512 entries */ + if (listen(s, 511) == -1) { anetSetError(err, "listen: %s", strerror(errno)); close(s); return ANET_ERR;