]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: config: continue to rely on DEFAULT_MAXCONN to set the minimum maxconn
authorWilly Tarreau <w@1wt.eu>
Wed, 13 Mar 2019 09:10:49 +0000 (10:10 +0100)
committerWilly Tarreau <w@1wt.eu>
Wed, 13 Mar 2019 09:10:49 +0000 (10:10 +0100)
Some packages used to rely on DEFAULT_MAXCONN to set the default global
maxconn value to use regardless of the initial ulimit. The recent changes
made the lowest bound set to 100 so that it is compatible with almost any
environment. Now that DEFAULT_MAXCONN is not needed for anything else, we
can use it for the lowest bound set when maxconn is not configured. This
way it retains its original purpose of setting the default maxconn value
eventhough most of the time the effective value will be higher thanks to
the automatic computation based on "ulimit -n".

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

index 80ef2c955bb572e69e6628f17961f72664dddc42..fbacca481e7f92d101ec47300762155ecdc97581 100644 (file)
  * absolute limit accepted by the system. If the configuration specifies a
  * higher value, it will be capped to SYSTEM_MAXCONN and a warning will be
  * emitted. The only way to override this limit will be to set it via the
- * command-line '-n' argument.
+ * command-line '-n' argument. If SYSTEM_MAXCONN is not set, a minimum value
+ * of 100 will be used for DEFAULT_MAXCONN which almost guarantees that a
+ * process will correctly start in any situation.
  */
 #ifdef SYSTEM_MAXCONN
 #undef  DEFAULT_MAXCONN
 #define DEFAULT_MAXCONN SYSTEM_MAXCONN
+#elif !defined(DEFAULT_MAXCONN)
+#define DEFAULT_MAXCONN 100
 #endif
 
 /* Minimum check interval for spread health checks. Servers with intervals
index 7095d70d91bd819be47b5c47fa29f1408dd855ef..317acebbb72638ac1fd9220cb12b230749cbf3db 100644 (file)
@@ -1452,9 +1452,11 @@ static int compute_ideal_maxpipes()
 /* considers global.maxsocks, global.maxpipes, async engines, SSL frontends and
  * rlimits and computes an ideal maxconn. It's meant to be called only when
  * maxsock contains the sum of listening FDs, before it is updated based on
- * maxconn and pipes. If there are not enough FDs left, 100 is returned as it
- * is expected that it will even run on tight environments. The system will
- * emit a warning indicating how many FDs are missing anyway.
+ * maxconn and pipes. If there are not enough FDs left, DEFAULT_MAXCONN (by
+ * default 100) is returned as it is expected that it will even run on tight
+ * environments, and will maintain compatibility with previous packages that
+ * used to rely on this value as the default one. The system will emit a
+ * warning indicating how many FDs are missing anyway if needed.
  */
 static int compute_ideal_maxconn()
 {
@@ -1495,7 +1497,7 @@ static int compute_ideal_maxconn()
                maxconn = remain / (2 + engine_fds);
        }
 
-       return MAX(maxconn, 100);
+       return MAX(maxconn, DEFAULT_MAXCONN);
 }
 
 /*