]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MEDIUM: proxy: make get_backend_server() use findproxy() to lookup proxies
authorWilly Tarreau <w@1wt.eu>
Sat, 15 Mar 2014 06:57:11 +0000 (07:57 +0100)
committerWilly Tarreau <w@1wt.eu>
Sat, 15 Mar 2014 06:57:11 +0000 (07:57 +0100)
This one is used by stats to look up proxy and server names in server state
manipulation. Get rid of the linear search.

src/proxy.c

index c2ba2ccde6bf47e4c52181858b531d2206e85123..2f2eb494c59eca01f2b04a9fca6fa23699e698bf 100644 (file)
@@ -97,22 +97,15 @@ int get_backend_server(const char *bk_name, const char *sv_name,
 {
        struct proxy *p;
        struct server *s;
-       int pid, sid;
+       int sid;
 
        *sv = NULL;
 
-       pid = -1;
-       if (*bk_name == '#')
-               pid = atoi(bk_name + 1);
        sid = -1;
        if (*sv_name == '#')
                sid = atoi(sv_name + 1);
 
-       for (p = proxy; p; p = p->next)
-               if ((p->cap & PR_CAP_BE) &&
-                   ((pid >= 0 && p->uuid == pid) ||
-                    (pid < 0 && strcmp(p->id, bk_name) == 0)))
-                       break;
+       p = findproxy(bk_name, PR_CAP_BE);
        if (bk)
                *bk = p;
        if (!p)