]> 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>
Sun, 10 May 2009 16:19:21 +0000 (18:19 +0200)
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
src/proto_uxst.c

index b0366e199fcb223018ed2cf0356008a321e6c131..4a4ad5d6a27713149d6b53183d4233adbf14cf61 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 c8e844b1fc5b9997500c0440339c0739ef520577..6fb0b5bd5b8e3963c2250a0cb4f3fe9f809f3cef 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);