]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: proxy: Add a "server by name" tree to proxy.
authorFrédéric Lécaille <flecaille@haproxy.com>
Fri, 17 May 2019 12:29:15 +0000 (14:29 +0200)
committerWilly Tarreau <w@1wt.eu>
Wed, 5 Jun 2019 06:33:35 +0000 (08:33 +0200)
Add a tree to proxy struct to lookup by name for servers attached
to this proxy and populated it at parsing time.

include/types/proxy.h
include/types/server.h
src/cfgparse.c

index 45ef2c824acd191f6eb211e1129b4392356ca4b1..ca24dbfe0c652d481921e71b277131a6010193cf 100644 (file)
@@ -447,6 +447,7 @@ struct proxy {
                int line;                       /* line where the section appears */
                struct eb_root used_listener_id;/* list of listener IDs in use */
                struct eb_root used_server_id;  /* list of server IDs in use */
+               struct eb_root used_server_name; /* list of server names in use */
                struct list bind;               /* list of bind settings */
                struct list listeners;          /* list of listeners belonging to this frontend */
                struct arg_list args;           /* sample arg list that need to be resolved */
index 219f5ab1df61e827988d49bbc6df87525ea2b4fe..574d40ee78db6db4fb444eeeef6abb276bbd847c 100644 (file)
@@ -320,6 +320,7 @@ struct server {
        struct {
                const char *file;               /* file where the section appears */
                struct eb32_node id;            /* place in the tree of used IDs */
+               struct ebpt_node name;          /* place in the tree of used names */
                int line;                       /* line where the section appears */
        } conf;                                 /* config information */
        /* Template information used only for server objects which
index 5b5941322d7740f3306beff5cc912b03590ab1fe..bec5b01f88b17989794f9026e7ccde7decdfbceb 100644 (file)
@@ -3143,6 +3143,8 @@ out_uri_auth_compat:
                                next_id = get_next_id(&curproxy->conf.used_server_id, next_id);
                                newsrv->conf.id.key = newsrv->puid = next_id;
                                eb32_insert(&curproxy->conf.used_server_id, &newsrv->conf.id);
+                               newsrv->conf.name.key = newsrv->id;
+                               ebis_insert(&curproxy->conf.used_server_name, &newsrv->conf.name);
                        }
                        next_id++;
                        newsrv = newsrv->next;