]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
[BUG] check for global.maxconn before doing accept()
authorWilly Tarreau <w@1wt.eu>
Sat, 21 Mar 2009 21:43:12 +0000 (22:43 +0100)
committerWilly Tarreau <w@1wt.eu>
Sat, 21 Mar 2009 21:43:12 +0000 (22:43 +0100)
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
src/proto_uxst.c

index 05ee8d540ce5ec002ac7198e6a5932bd2c5ff182..02c7c02daa5c6490f335200d6fa428a24146c1d9 100644 (file)
@@ -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);
 
index 0eaea3c40b4f7f9b9cfa10c292acbba63ac9a992..599252a1fb7d478909cb7da35308af665f2622fd 100644 (file)
@@ -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);