[cherry-picked from commit
b00f9c456c0eadd26abbbf4bb0a3276da9f1844e]
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.
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);
else
max_accept = -1;
- while (max_accept--) {
+ while (actconn < global.maxconn && max_accept--) {
struct sockaddr_storage addr;
socklen_t laddr = sizeof(addr);