MINOR: log/backend: ensure log exclusive params are not used in other modes
add proxy_cfg_ensure_no_log() function (similar to proxy_cfg_ensure_no_http()) to ensure at the end of proxy parsing that no log exclusive options are found if the proxy is not in log mode.
This commit is contained in:
parent
42d7d1bd47
commit
6a29888f60
|
@ -62,6 +62,7 @@ struct server *findserver(const struct proxy *px, const char *name);
|
|||
struct server *findserver_unique_id(const struct proxy *px, int puid, uint32_t rid);
|
||||
struct server *findserver_unique_name(const struct proxy *px, const char *name, uint32_t rid);
|
||||
int proxy_cfg_ensure_no_http(struct proxy *curproxy);
|
||||
int proxy_cfg_ensure_no_log(struct proxy *curproxy);
|
||||
void init_new_proxy(struct proxy *p);
|
||||
void proxy_preset_defaults(struct proxy *defproxy);
|
||||
void proxy_free_defaults(struct proxy *defproxy);
|
||||
|
|
|
@ -2939,14 +2939,17 @@ int check_config_validity()
|
|||
switch (curproxy->mode) {
|
||||
case PR_MODE_TCP:
|
||||
cfgerr += proxy_cfg_ensure_no_http(curproxy);
|
||||
cfgerr += proxy_cfg_ensure_no_log(curproxy);
|
||||
break;
|
||||
|
||||
case PR_MODE_HTTP:
|
||||
cfgerr += proxy_cfg_ensure_no_log(curproxy);
|
||||
curproxy->http_needed = 1;
|
||||
break;
|
||||
|
||||
case PR_MODE_CLI:
|
||||
cfgerr += proxy_cfg_ensure_no_http(curproxy);
|
||||
cfgerr += proxy_cfg_ensure_no_log(curproxy);
|
||||
break;
|
||||
|
||||
case PR_MODE_SYSLOG:
|
||||
|
|
18
src/proxy.c
18
src/proxy.c
|
@ -1375,6 +1375,24 @@ int proxy_cfg_ensure_no_http(struct proxy *curproxy)
|
|||
return 0;
|
||||
}
|
||||
|
||||
/* This function checks that the designated proxy has no log directives
|
||||
* enabled. It will output a warning if there are, and will fix some of them.
|
||||
* It returns the number of fatal errors encountered. This should be called
|
||||
* at the end of the configuration parsing if the proxy is not in log mode.
|
||||
* The <file> argument is used to construct the error message.
|
||||
*/
|
||||
int proxy_cfg_ensure_no_log(struct proxy *curproxy)
|
||||
{
|
||||
if (curproxy->lbprm.algo & BE_LB_NEED_LOG) {
|
||||
curproxy->lbprm.algo &= ~BE_LB_ALGO;
|
||||
curproxy->lbprm.algo |= BE_LB_ALGO_RR;
|
||||
ha_warning("Unusable balance algorithm for %s '%s' (needs 'mode log'). Falling back to round robin.\n",
|
||||
proxy_type_str(curproxy), curproxy->id);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Perform the most basic initialization of a proxy :
|
||||
* memset(), list_init(*), reset_timeouts(*).
|
||||
* Any new proxy or peer should be initialized via this function.
|
||||
|
|
Loading…
Reference in New Issue