]> git.kaiwu.me - 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:47:32 +0000 (22:47 +0100)
[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.

src/client.c
src/proto_uxst.c

index 1dd318f5ee78d26469e3346e47c01d0fd0a3c7a8..9498b138d1d47b32f2f109df8fbb8f887b37776f 100644 (file)
@@ -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);
 
index b708689c11e133372f9f77f727602e0839c95473..76854f2d4df2f9214350a61de9c83f83544d1f07 100644 (file)
@@ -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);