[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.
diff --git a/src/client.c b/src/client.c
index 05ee8d5..02c7c02 100644
--- a/src/client.c
+++ b/src/client.c
@@ -76,7 +76,7 @@
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 0eaea3c..599252a 100644
--- a/src/proto_uxst.c
+++ b/src/proto_uxst.c
@@ -368,7 +368,7 @@
else
max_accept = -1;
- while (max_accept--) {
+ while (actconn < global.maxconn && max_accept--) {
struct sockaddr_storage addr;
socklen_t laddr = sizeof(addr);