Commit 815c06f2 authored by Erik Dubbelboer's avatar Erik Dubbelboer
Browse files

added explanation for the magic 511 backlog number

parent 69e79589
...@@ -262,7 +262,11 @@ static int anetListen(char *err, int s, struct sockaddr *sa, socklen_t len) { ...@@ -262,7 +262,11 @@ static int anetListen(char *err, int s, struct sockaddr *sa, socklen_t len) {
close(s); close(s);
return ANET_ERR; 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)); anetSetError(err, "listen: %s", strerror(errno));
close(s); close(s);
return ANET_ERR; return ANET_ERR;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment