unsigned long last_change; /* internal use only (not for stats purpose): last time the server state was changed, doesn't change often, not updated atomically on purpose */
char *id; /* just for identification */
+
uint32_t rid; /* revision: if id has been reused for a new server, rid won't match */
unsigned iweight,uweight, cur_eweight; /* initial weight, user-specified weight, and effective weight */
unsigned wscore; /* weight score, used during srv map computation */
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 */
+ struct ceb_node name_node; /* place in the tree of used names, indexes <id> above, not unique, indexed in px->used_server_name */
int line; /* line where the section appears */
} conf; /* config information */
#include <sys/stat.h>
#include <unistd.h>
+#include <import/cebis_tree.h>
+
#include <haproxy/acl.h>
#include <haproxy/action.h>
#include <haproxy/api.h>
/* Note: internal servers are not always registered and
* they do not conflict.
*/
- if (!newsrv->conf.name.node.leaf_p)
+ if (!ceb_intree(&newsrv->conf.name_node))
continue;
for (other_srv = newsrv;
- (other_srv = container_of_safe(ebpt_prev_dup(&other_srv->conf.name),
- struct server, conf.name)); ) {
+ (other_srv = cebis_item_prev_dup(&curproxy->conf.used_server_name, conf.name_node, id, other_srv)); ) {
ha_alert("parsing [%s:%d] : %s '%s', another server named '%s' was already defined at line %d, please use distinct names.\n",
newsrv->conf.file, newsrv->conf.line,
proxy_type_str(curproxy), curproxy->id,
//BUG_ON(ceb_intree(&srv->addr_node) ||
// srv->idle_node.node.leaf_p ||
// srv->conf.id.node.leaf_p ||
- // srv->conf.name.node.leaf_p);
+ // ceb_intree(&srv->name_node));
guid_remove(&srv->guid);
/* Set the first server's ID. */
_srv_parse_set_id_from_prefix(srv, srv->tmpl_info.prefix, srv->tmpl_info.nb_low);
- srv->conf.name.key = srv->id;
- ebis_insert(&curproxy->conf.used_server_name, &srv->conf.name);
+ cebis_item_insert(&curproxy->conf.used_server_name, conf.name_node, id, srv);
/* then create other servers from this one */
for (i = srv->tmpl_info.nb_low + 1; i <= srv->tmpl_info.nb_high; i++) {
/* Set this new server ID. */
_srv_parse_set_id_from_prefix(newsrv, srv->tmpl_info.prefix, i);
- newsrv->conf.name.key = newsrv->id;
- ebis_insert(&curproxy->conf.used_server_name, &newsrv->conf.name);
+ cebis_item_insert(&curproxy->conf.used_server_name, conf.name_node, id, newsrv);
}
return i - srv->tmpl_info.nb_low;
_srv_parse_tmpl_init(newsrv, curproxy);
}
else if (!(parse_flags & SRV_PARSE_DEFAULT_SERVER)) {
- newsrv->conf.name.key = newsrv->id;
- ebis_insert(&curproxy->conf.used_server_name, &newsrv->conf.name);
+ cebis_item_insert(&curproxy->conf.used_server_name, conf.name_node, id, newsrv);
}
/* If the server id is fixed, insert it in the proxy used_id tree.
*/
struct server *server_find_by_name(struct proxy *px, const char *name)
{
- struct ebpt_node *node;
- struct server *cursrv;
-
if (!px)
return NULL;
- node = ebis_lookup(&px->conf.used_server_name, name);
- cursrv = node ? container_of(node, struct server, conf.name) : NULL;
- return cursrv;
+ return cebis_item_lookup(&px->conf.used_server_name, conf.name_node, id, name, struct server);
}
/*
srv->conf.id.key = srv->puid = next_id;
}
- srv->conf.name.key = srv->id;
/* insert the server in the backend trees */
eb32_insert(&be->conf.used_server_id, &srv->conf.id);
- ebis_insert(&be->conf.used_server_name, &srv->conf.name);
+ cebis_item_insert(&be->conf.used_server_name, conf.name_node, id, srv);
/* addr_key could be NULL if FQDN resolution is postponed (ie: add server from cli) */
if (srv->addr_key)
cebuis_item_insert(&be->used_server_addr, addr_node, addr_key, srv);
/* remove srv from addr_node tree */
eb32_delete(&srv->conf.id);
- ebpt_delete(&srv->conf.name);
+ cebis_item_delete(&be->conf.used_server_name, conf.name_node, id, srv);
cebuis_item_delete(&be->used_server_addr, addr_node, addr_key, srv);
/* remove srv from idle_node tree for idle conn cleanup */