BUG/MINOR: config: don't over-count the global maxsock value

global.maxsock used to be augmented by the frontend's maxconn value
for each frontend listener, which is absurd when there are many
listeners in a frontend because the frontend's maxconn fixes an
upper limit to how many connections will be accepted on all of its
listeners anyway. What is needed instead is to add one to count the
listening socket.

In addition, the CLI's and peers' value was incremented twice, the
first time when creating the listener and the second time in the
main init code.

Let's now make sure we only increment global.maxsock by the required
amount of sockets. This means not adding maxconn for each listener,
and relying on the global values when they are correct.
This commit is contained in:
Willy Tarreau 2019-02-27 16:25:28 +01:00
parent 3f36448e17
commit 18215cba6a
2 changed files with 6 additions and 5 deletions

View File

@ -655,7 +655,7 @@ int cfg_parse_peers(const char *file, int linenum, char **args, int kwm)
l->analysers |= curpeers->peers_fe->fe_req_ana; l->analysers |= curpeers->peers_fe->fe_req_ana;
l->default_target = curpeers->peers_fe->default_target; l->default_target = curpeers->peers_fe->default_target;
l->options |= LI_O_UNLIMITED; /* don't make the peers subject to global limits */ l->options |= LI_O_UNLIMITED; /* don't make the peers subject to global limits */
global.maxsock += l->maxconn; global.maxsock++; /* for the listening socket */
bind_line = 1; bind_line = 1;
if (cfg_peers->local) { if (cfg_peers->local) {
@ -859,7 +859,7 @@ int cfg_parse_peers(const char *file, int linenum, char **args, int kwm)
l->analysers |= curpeers->peers_fe->fe_req_ana; l->analysers |= curpeers->peers_fe->fe_req_ana;
l->default_target = curpeers->peers_fe->default_target; l->default_target = curpeers->peers_fe->default_target;
l->options |= LI_O_UNLIMITED; /* don't make the peers subject to global limits */ l->options |= LI_O_UNLIMITED; /* don't make the peers subject to global limits */
global.maxsock += l->maxconn; global.maxsock++; /* for the listening socket */
} /* neither "peer" nor "peers" */ } /* neither "peer" nor "peers" */
else if (!strcmp(args[0], "disabled")) { /* disables this peers section */ else if (!strcmp(args[0], "disabled")) { /* disables this peers section */
curpeers->state = PR_STSTOPPED; curpeers->state = PR_STSTOPPED;

View File

@ -303,7 +303,7 @@ static int stats_parse_global(char **args, int section_type, struct proxy *curpx
l->default_target = global.stats_fe->default_target; l->default_target = global.stats_fe->default_target;
l->options |= LI_O_UNLIMITED; /* don't make the peers subject to global limits */ l->options |= LI_O_UNLIMITED; /* don't make the peers subject to global limits */
l->nice = -64; /* we want to boost priority for local stats */ l->nice = -64; /* we want to boost priority for local stats */
global.maxsock += l->maxconn; global.maxsock++; /* for the listening socket */
} }
} }
else if (!strcmp(args[1], "timeout")) { else if (!strcmp(args[1], "timeout")) {
@ -2528,8 +2528,9 @@ int mworker_cli_proxy_new_listener(char *line)
/* don't make the peers subject to global limits and don't close it in the master */ /* don't make the peers subject to global limits and don't close it in the master */
l->options |= (LI_O_UNLIMITED|LI_O_MWORKER); /* we are keeping this FD in the master */ l->options |= (LI_O_UNLIMITED|LI_O_MWORKER); /* we are keeping this FD in the master */
l->nice = -64; /* we want to boost priority for local stats */ l->nice = -64; /* we want to boost priority for local stats */
global.maxsock += l->maxconn; global.maxsock++; /* for the listening socket */
} }
global.maxsock += mworker_proxy->maxconn;
return 0; return 0;
@ -2598,7 +2599,7 @@ int mworker_cli_sockpair_new(struct mworker_proc *mworker_proc, int proc)
/* it's a sockpair but we don't want to keep the fd in the master */ /* it's a sockpair but we don't want to keep the fd in the master */
l->options &= ~LI_O_INHERITED; l->options &= ~LI_O_INHERITED;
l->nice = -64; /* we want to boost priority for local stats */ l->nice = -64; /* we want to boost priority for local stats */
global.maxsock += l->maxconn; global.maxsock++; /* for the listening socket */
} }
return 0; return 0;