]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
[MINOR] server tracking: don't care about the tracked server's mode
authorAlex Williams <alex@alexwilliams.ca>
Mon, 2 Nov 2009 02:27:13 +0000 (21:27 -0500)
committerWilly Tarreau <w@1wt.eu>
Sun, 6 Dec 2009 12:20:08 +0000 (13:20 +0100)
Right now, an HTTP server cannot track a TCP server and vice-versa.
This patch enables proxy tracking without relying on the proxy's mode
(tcp/http/health). It only requires a matching proxy name to exist. The
original function was renamed to findproxy_mode().

(cherry picked from commit 96532db9237419b69008bb85c1e557374014420b)

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

index 8a2789df1ee706593c71c3bfb7ec18fd539a1b7d..4bea3ef16fcf3af88c0671c364a5e43a29908e11 100644 (file)
@@ -38,7 +38,8 @@ void listen_proxies(void);
 
 const char *proxy_cap_str(int cap);
 const char *proxy_mode_str(int mode);
-struct proxy *findproxy(const char *name, int mode, int cap);
+struct proxy *findproxy_mode(const char *name, int mode, int cap);
+struct proxy *findproxy(const char *name, int cap);
 struct server *findserver(const struct proxy *px, const char *name);
 int proxy_cfg_ensure_no_http(struct proxy *curproxy);
 
index bc9fdfecaaa99c732e81155c641aa5e810cafeef..f80a45d5df34b284f27ebccabdfb588fb87c0dad 100644 (file)
@@ -3913,7 +3913,7 @@ int check_config_validity()
                if (curproxy->defbe.name) {
                        struct proxy *target;
 
-                       target = findproxy(curproxy->defbe.name, curproxy->mode, PR_CAP_BE);
+                       target = findproxy_mode(curproxy->defbe.name, curproxy->mode, PR_CAP_BE);
                        if (!target) {
                                Alert("Proxy '%s': unable to find required default_backend: '%s'.\n",
                                        curproxy->id, curproxy->defbe.name);
@@ -3943,7 +3943,7 @@ int check_config_validity()
                                if (exp->action != ACT_SETBE)
                                        continue;
 
-                               target = findproxy(exp->replace, PR_MODE_HTTP, PR_CAP_BE);
+                               target = findproxy_mode(exp->replace, PR_MODE_HTTP, PR_CAP_BE);
                                if (!target) {
                                        Alert("Proxy '%s': unable to find required setbe: '%s'.\n",
                                                curproxy->id, exp->replace);
@@ -3968,7 +3968,7 @@ int check_config_validity()
                list_for_each_entry(rule, &curproxy->switching_rules, list) {
                        struct proxy *target;
 
-                       target = findproxy(rule->be.name, curproxy->mode, PR_CAP_BE);
+                       target = findproxy_mode(rule->be.name, curproxy->mode, PR_CAP_BE);
 
                        if (!target) {
                                Alert("Proxy '%s': unable to find required use_backend: '%s'.\n",
@@ -4145,7 +4145,7 @@ int check_config_validity()
                                }
 
                                if (pname) {
-                                       px = findproxy(pname, curproxy->mode, PR_CAP_BE);
+                                       px = findproxy(pname, PR_CAP_BE);
                                        if (!px) {
                                                Alert("config : %s '%s', server '%s': unable to find required proxy '%s' for tracking.\n",
                                                        proxy_type_str(curproxy), curproxy->id,
@@ -4167,7 +4167,7 @@ int check_config_validity()
 
                                if (!(srv->state & SRV_CHECKED)) {
                                        Alert("config : %s '%s', server '%s': unable to use %s/%s for "
-                                               "tracing as it does not have checks enabled.\n",
+                                               "tracking as it does not have checks enabled.\n",
                                                proxy_type_str(curproxy), curproxy->id,
                                                newsrv->id, px->id, srv->id);
                                        cfgerr++;
index 15f9b92d9e6c886b9eb249a3c2784b40541434aa..f996713e8a2188ae7d7f11d2fba2af5b6ce51467 100644 (file)
@@ -237,7 +237,7 @@ static int proxy_parse_rate_limit(char **args, int section, struct proxy *proxy,
  * requested name as this often leads into unexpected situations.
  */
 
-struct proxy *findproxy(const char *name, int mode, int cap) {
+struct proxy *findproxy_mode(const char *name, int mode, int cap) {
 
        struct proxy *curproxy, *target = NULL;
 
@@ -266,6 +266,25 @@ struct proxy *findproxy(const char *name, int mode, int cap) {
        return target;
 }
 
+struct proxy *findproxy(const char *name, int cap) {
+
+       struct proxy *curproxy, *target = NULL;
+
+       for (curproxy = proxy; curproxy; curproxy = curproxy->next) {
+               if ((curproxy->cap & cap)!=cap || strcmp(curproxy->id, name))
+                       continue;
+
+               if (!target) {
+                       target = curproxy;
+                       continue;
+               }
+
+               return NULL;
+       }
+
+       return target;
+}
+
 /*
  * This function finds a server with matching name within selected proxy.
  * It also checks if there are more matching servers with