]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: mworker: use MASTER_MAXCONN as default maxconn value
authorWilliam Lallemand <wlallemand@haproxy.org>
Thu, 9 Mar 2023 13:28:44 +0000 (14:28 +0100)
committerWilliam Lallemand <wlallemand@haproxy.org>
Thu, 9 Mar 2023 13:28:44 +0000 (14:28 +0100)
In environments where SYSTEM_MAXCONN is defined when compiling, the
master will use this value instead of the original minimal value which
was set to 100. When this happens, the master process could allocate
RAM excessively since it does not need to have an high maxconn. (For
example if SYSTEM_MAXCONN was set to 100000 or more)

This patch fixes the issue by using the new define MASTER_MAXCONN which
define a default maxconn of 100 for the master process.

Must be backported as far as 2.5.

include/haproxy/defaults.h
src/haproxy.c

index f5f3b545954e3d277d7ad970ee3cba3ca62af0fe..0dc25818d833a7683979ffffc8504ba467d650bf 100644 (file)
 #define DEFAULT_MAXCONN 100
 #endif
 
+/* Define a maxconn which will be used in the master process once it re-exec to
+ * the MODE_MWORKER_WAIT and won't change when SYSTEM_MAXCONN is set.
+ *
+ * 100 must be enough for the master since it only does communication between
+ * the master and the workers, and the master CLI.
+ */
+#ifndef MASTER_MAXCONN
+#define MASTER_MAXCONN 100
+#endif
+
 /* Minimum check interval for spread health checks. Servers with intervals
  * greater than or equal to this value will have their checks spread apart
  * and will be considered when searching the minimal interval.
index 19463f29e1286908b38952cad3220b66ba473a96..3def1ed98374c183e63074f047d57414fe4fbd7a 100644 (file)
@@ -2380,7 +2380,7 @@ static void init(int argc, char **argv)
 
        /* set the default maxconn in the master, but let it be rewritable with -n */
        if (global.mode & MODE_MWORKER_WAIT)
-               global.maxconn = DEFAULT_MAXCONN;
+               global.maxconn = MASTER_MAXCONN;
 
        if (cfg_maxconn > 0)
                global.maxconn = cfg_maxconn;