From b00f9c456c0eadd26abbbf4bb0a3276da9f1844e Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Sat, 21 Mar 2009 22:43:12 +0100 Subject: [PATCH] [BUG] check for global.maxconn before doing accept() If the accept() is done before checking for global.maxconn, we can accept too many connections and encounter a lack of file descriptors when trying to connect to the server. This is the cause of the "cannot get a server socket" message encountered in debug mode during injections with low timeouts. --- src/client.c | 2 +- src/proto_uxst.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/client.c b/src/client.c index 05ee8d540..02c7c02da 100644 --- a/src/client.c +++ b/src/client.c @@ -76,7 +76,7 @@ int event_accept(int fd) { max_accept = max; } - while (p->feconn < p->maxconn && max_accept--) { + while (p->feconn < p->maxconn && actconn < global.maxconn && max_accept--) { struct sockaddr_storage addr; socklen_t laddr = sizeof(addr); diff --git a/src/proto_uxst.c b/src/proto_uxst.c index 0eaea3c40..599252a1f 100644 --- a/src/proto_uxst.c +++ b/src/proto_uxst.c @@ -368,7 +368,7 @@ int uxst_event_accept(int fd) { else max_accept = -1; - while (max_accept--) { + while (actconn < global.maxconn && max_accept--) { struct sockaddr_storage addr; socklen_t laddr = sizeof(addr);