mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-09-29 01:31:19 +02:00
MINOR: cfgparse/server: move (min/max)conn postparsing logic into dedicated function
In check_config_validity() function, we performed some consistency checks to adjust minconn/maxconn attributes for each declared server. We move this logic into a dedicated function named srv_minmax_conn_apply() to be able to perform those checks later in the process life when needed (ie: dynamic servers)
This commit is contained in:
parent
a14686d096
commit
3e7a0bb70b
@ -281,6 +281,26 @@ static inline void srv_use_conn(struct server *srv, struct connection *conn)
|
|||||||
HA_ATOMIC_STORE(&srv->est_need_conns, curr);
|
HA_ATOMIC_STORE(&srv->est_need_conns, curr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* checks if minconn and maxconn are consistent to each other
|
||||||
|
* and automatically adjust them if it is not the case
|
||||||
|
* This logic was historically implemented in check_config_validity()
|
||||||
|
* at boot time, but with the introduction of dynamic servers
|
||||||
|
* this may be used at multiple places in the code now
|
||||||
|
*/
|
||||||
|
static inline void srv_minmax_conn_apply(struct server *srv)
|
||||||
|
{
|
||||||
|
if (srv->minconn > srv->maxconn) {
|
||||||
|
/* Only 'minconn' was specified, or it was higher than or equal
|
||||||
|
* to 'maxconn'. Let's turn this into maxconn and clean it, as
|
||||||
|
* this will avoid further useless expensive computations.
|
||||||
|
*/
|
||||||
|
srv->maxconn = srv->minconn;
|
||||||
|
} else if (srv->maxconn && !srv->minconn) {
|
||||||
|
/* minconn was not specified, so we set it to maxconn */
|
||||||
|
srv->minconn = srv->maxconn;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endif /* _HAPROXY_SERVER_H */
|
#endif /* _HAPROXY_SERVER_H */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -3818,16 +3818,7 @@ out_uri_auth_compat:
|
|||||||
while (newsrv != NULL) {
|
while (newsrv != NULL) {
|
||||||
set_usermsgs_ctx(newsrv->conf.file, newsrv->conf.line, &newsrv->obj_type);
|
set_usermsgs_ctx(newsrv->conf.file, newsrv->conf.line, &newsrv->obj_type);
|
||||||
|
|
||||||
if (newsrv->minconn > newsrv->maxconn) {
|
srv_minmax_conn_apply(newsrv);
|
||||||
/* Only 'minconn' was specified, or it was higher than or equal
|
|
||||||
* to 'maxconn'. Let's turn this into maxconn and clean it, as
|
|
||||||
* this will avoid further useless expensive computations.
|
|
||||||
*/
|
|
||||||
newsrv->maxconn = newsrv->minconn;
|
|
||||||
} else if (newsrv->maxconn && !newsrv->minconn) {
|
|
||||||
/* minconn was not specified, so we set it to maxconn */
|
|
||||||
newsrv->minconn = newsrv->maxconn;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* this will also properly set the transport layer for
|
/* this will also properly set the transport layer for
|
||||||
* prod and checks
|
* prod and checks
|
||||||
|
Loading…
x
Reference in New Issue
Block a user