[MINOR] adjust error messages about conflicting proxies

It's not easy to report useful information to help the user quickly
fix a configuration. This patch :
  - removes the word "listener" in favor of "proxy" as it has been
    used since the beginning ;

  - ensures that the same function (hence the same words) will be
    used to report capabilities of a proxy being declared and an
    existing proxy ;

  - avoid the term "conflicting capabilities" in favor of "overlapping
    capabilities" which is more exact.

  - just report that the same name is reused in case of warnings
This commit is contained in:
Willy Tarreau 2007-11-04 07:04:43 +01:00
parent 6eb730ded9
commit 816eb54e9b
3 changed files with 27 additions and 19 deletions

View File

@ -33,10 +33,19 @@ void pause_proxy(struct proxy *p);
void pause_proxies(void);
void listen_proxies(void);
const char *proxy_type_str(struct proxy *proxy);
const char *proxy_cap_str(int cap);
const char *proxy_mode_str(int mode);
struct proxy *findproxy(const char *name, int mode, int cap);
/*
* This function returns a string containing the type of the proxy in a format
* suitable for error messages, from its capabilities.
*/
static inline const char *proxy_type_str(struct proxy *proxy)
{
return proxy_cap_str(proxy->cap);
}
#endif /* _PROTO_PROXY_H */
/*

View File

@ -539,8 +539,8 @@ int cfg_parse_listen(const char *file, int linenum, char **args)
if (!strcmp(curproxy->id, args[1]) &&
(rc!=(PR_CAP_FE|PR_CAP_RS) || curproxy->cap!=(PR_CAP_BE|PR_CAP_RS)) &&
(rc!=(PR_CAP_BE|PR_CAP_RS) || curproxy->cap!=(PR_CAP_FE|PR_CAP_RS))) {
Warning("Parsing [%s:%d]: duplicated proxy '%s' with conflicting capabilities: %s/%s!\n",
file, linenum, args[1], proxy_type_str(curproxy), args[0]);
Warning("Parsing [%s:%d]: %s '%s' has same name as another %s.\n",
file, linenum, proxy_cap_str(rc), args[1], proxy_type_str(curproxy));
}
}

View File

@ -37,29 +37,28 @@ int listeners; /* # of listeners */
struct proxy *proxy = NULL; /* list of all existing proxies */
/*
* This function returns a string containing the type of the proxy in a format
* suitable for error messages, from its capabilities.
* This function returns a string containing a name describing capabilities to
* report comprehensible error messages. Specifically, it will return the words
* "frontend", "backend", "ruleset" when appropriate, or "proxy" for all other
* cases including the proxies declared in "listen" mode.
*/
const char *proxy_type_str(struct proxy *proxy)
const char *proxy_cap_str(int cap)
{
int cap = proxy->cap;
if ((cap & PR_CAP_LISTEN) == PR_CAP_LISTEN)
return "listener";
else if (cap & PR_CAP_FE)
return "frontend";
else if (cap & PR_CAP_BE)
return "backend";
else if (cap & PR_CAP_RS)
return "ruleset";
else
return "proxy";
if ((cap & PR_CAP_LISTEN) != PR_CAP_LISTEN) {
if (cap & PR_CAP_FE)
return "frontend";
else if (cap & PR_CAP_BE)
return "backend";
else if (cap & PR_CAP_RS)
return "ruleset";
}
return "proxy";
}
/*
* This function returns a string containing the mode of the proxy in a format
* suitable for error messages.
*/
const char *proxy_mode_str(int mode) {
if (mode == PR_MODE_TCP)
@ -98,7 +97,7 @@ struct proxy *findproxy(const char *name, int mode, int cap) {
continue;
}
Alert("Refusing to use duplicated proxy '%s' with conflicting capabilities: %s/%s!\n",
Alert("Refusing to use duplicated proxy '%s' with overlapping capabilities: %s/%s!\n",
name, proxy_type_str(curproxy), proxy_type_str(target));
return NULL;