From 099a7985a614aa88efebf49e2b8910175051c8b6 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. (cherry-picked from commit b00f9c456c0eadd26abbbf4bb0a3276da9f1844e) (cherry picked from commit dea567ef66e1f0d6eafe29ff8a9c68b54ff40c90) --- 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 b0366e199..4a4ad5d6a 100644 --- a/src/client.c +++ b/src/client.c @@ -76,7 +76,7 @@ int event_accept(int fd) { int cfd; int max_accept = global.tune.maxaccept; - 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 c8e844b1f..6fb0b5bd5 100644 --- a/src/proto_uxst.c +++ b/src/proto_uxst.c @@ -374,7 +374,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); -- 2.47.3