MINOR: config: continue to rely on DEFAULT_MAXCONN to set the minimum maxconn

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".
This commit is contained in:
Willy Tarreau 2019-03-13 10:10:49 +01:00
parent ca783d4ee6
commit df23c0ce45
2 changed files with 11 additions and 5 deletions

View File

@ -192,11 +192,15 @@
* absolute limit accepted by the system. If the configuration specifies a * 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 * 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 * 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 #ifdef SYSTEM_MAXCONN
#undef DEFAULT_MAXCONN #undef DEFAULT_MAXCONN
#define DEFAULT_MAXCONN SYSTEM_MAXCONN #define DEFAULT_MAXCONN SYSTEM_MAXCONN
#elif !defined(DEFAULT_MAXCONN)
#define DEFAULT_MAXCONN 100
#endif #endif
/* Minimum check interval for spread health checks. Servers with intervals /* Minimum check interval for spread health checks. Servers with intervals

View File

@ -1452,9 +1452,11 @@ static int compute_ideal_maxpipes()
/* considers global.maxsocks, global.maxpipes, async engines, SSL frontends and /* considers global.maxsocks, global.maxpipes, async engines, SSL frontends and
* rlimits and computes an ideal maxconn. It's meant to be called only when * 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 * 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 * maxconn and pipes. If there are not enough FDs left, DEFAULT_MAXCONN (by
* is expected that it will even run on tight environments. The system will * default 100) is returned as it is expected that it will even run on tight
* emit a warning indicating how many FDs are missing anyway. * 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() static int compute_ideal_maxconn()
{ {
@ -1495,7 +1497,7 @@ static int compute_ideal_maxconn()
maxconn = remain / (2 + engine_fds); maxconn = remain / (2 + engine_fds);
} }
return MAX(maxconn, 100); return MAX(maxconn, DEFAULT_MAXCONN);
} }
/* /*