From 84d6046a33f97635154a60c3747a64aee647f336 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20L=C3=A9caille?= Date: Fri, 17 May 2019 14:29:15 +0200 Subject: [PATCH] MINOR: proxy: Add a "server by name" tree to proxy. 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 | 1 + include/types/server.h | 1 + src/cfgparse.c | 2 ++ 3 files changed, 4 insertions(+) diff --git a/include/types/proxy.h b/include/types/proxy.h index 45ef2c824..ca24dbfe0 100644 --- a/include/types/proxy.h +++ b/include/types/proxy.h @@ -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 */ diff --git a/include/types/server.h b/include/types/server.h index 219f5ab1d..574d40ee7 100644 --- a/include/types/server.h +++ b/include/types/server.h @@ -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 diff --git a/src/cfgparse.c b/src/cfgparse.c index 5b5941322..bec5b01f8 100644 --- a/src/cfgparse.c +++ b/src/cfgparse.c @@ -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;