]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
Limit the number of consecutive accept() in multi-process mode.
authorwilly tarreau <willy@wtap.(none)>
Sun, 19 Mar 2006 18:36:48 +0000 (19:36 +0100)
committerwilly tarreau <willy@wtap.(none)>
Sun, 19 Mar 2006 18:36:48 +0000 (19:36 +0100)
This produces a more evenly distributed load across the processes and slightly
improves performance by reducing bottlenecks.

haproxy.c

index bad84a0974b06a90a49d215d8ce62890aae07939..1b39264a3e96a3c2809254605d1b41a2eea3fd5a 100644 (file)
--- a/haproxy.c
+++ b/haproxy.c
@@ -2555,8 +2555,14 @@ int event_accept(int fd) {
     struct session *s;
     struct task *t;
     int cfd;
+    int max_accept;
 
-    while (p->nbconn < p->maxconn) {
+    if (global.nbproc > 1)
+           max_accept = 8; /* let other processes catch some connections too */
+    else
+           max_accept = -1;
+
+    while (p->nbconn < p->maxconn && max_accept--) {
        struct sockaddr_storage addr;
        socklen_t laddr = sizeof(addr);