]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
[MINOR] adjust error messages about conflicting proxies
authorWilly Tarreau <w@1wt.eu>
Sun, 4 Nov 2007 06:04:43 +0000 (07:04 +0100)
committerWilly Tarreau <w@1wt.eu>
Sun, 4 Nov 2007 07:14:25 +0000 (08:14 +0100)
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

include/proto/proxy.h
src/cfgparse.c
src/proxy.c

index 839cce5812bbef63494f888c072a10b11e833f28..a0c86cb877fdc7cafb228bbe4bda98a6279e2ee0 100644 (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 */
 
 /*
index fc333bfbbfd8a1cf2408212538652cbea7c0c749..0df66daae33338a2936e33027b8806f91d0f3b98 100644 (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));
                        }
                }
 
index 1f5481868f156f76c6006174ee67fb0d392608d4..feb93c2f3a054164a70ab0b34e8f06c60d018b87 100644 (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;