]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
* account for the sockets needed for listeners and checks
authorWilly TARREAU <willy@pcw.(none)>
Sun, 12 Mar 2006 17:00:28 +0000 (18:00 +0100)
committerWilly TARREAU <willy@pcw.(none)>
Sun, 12 Mar 2006 17:00:28 +0000 (18:00 +0100)
  during computation of maximum number of sockets.

haproxy.c

index 4998cdcfe98f4c993b553d488085519f5447ea7b..dd349e1da4083a8b2aab4832086df9a44b64e8a7 100644 (file)
--- a/haproxy.c
+++ b/haproxy.c
@@ -6253,6 +6253,7 @@ int cfg_parse_listen(char *file, int linenum, char **args) {
            curproxy->listen = str2listener(args[2], curproxy->listen);
            if (!curproxy->listen)
                return -1;
+           global.maxsock++;
        }
 
        /* set default values */
@@ -6355,6 +6356,7 @@ int cfg_parse_listen(char *file, int linenum, char **args) {
        curproxy->listen = str2listener(args[1], curproxy->listen);
        if (!curproxy->listen)
            return -1;
+       global.maxsock++;
        return 0;
     }
     else if (!strcmp(args[0], "monitor-net")) {  /* set the range of IPs to ignore */
@@ -6830,6 +6832,7 @@ int cfg_parse_listen(char *file, int linenum, char **args) {
                cur_arg ++;
            }
            else if (!strcmp(args[cur_arg], "check")) {
+               global.maxsock++;
                do_check = 1;
                cur_arg += 1;
            }
@@ -7852,6 +7855,7 @@ void init(int argc, char **argv) {
     gethostname(hostname, MAX_HOSTNAME_LEN);
 
     have_appsession = 0;
+    global.maxsock = 10; /* reserve 10 fds ; will be incremented by socket eaters */
     if (readcfgfile(cfg_cfgfile) < 0) {
        Alert("Error reading configuration file : %s\n", cfg_cfgfile);
        exit(1);
@@ -7876,7 +7880,7 @@ void init(int argc, char **argv) {
     if (global.maxconn == 0)
        global.maxconn = DEFAULT_MAXCONN;
 
-    global.maxsock = global.maxconn * 2; /* each connection needs two sockets */
+    global.maxsock += global.maxconn * 2; /* each connection needs two sockets */
 
     if (arg_mode & MODE_DEBUG) {
        /* command line debug mode inhibits configuration mode */