const char *srv_update_agent_addr_port(struct server *s, const char *addr, const char *port);
struct server *server_find_by_id_unique(struct proxy *bk, int id, uint32_t rid);
struct server *server_find_by_name(struct proxy *px, const char *name);
+struct server *server_find_by_name2(struct proxy *px, const char *name);
struct server *server_find_by_addr(struct proxy *px, const char *addr);
struct server *server_find(struct proxy *bk, const char *name);
struct server *server_find_unique(struct proxy *bk, const char *name, uint32_t rid);
goto out;
}
- if ((other = server_find_by_name(px, srv->id))) {
+ if ((other = server_find_by_name2(px, srv->id))) {
ha_alert("another server named '%s' was already defined at line %d, please use a distinct name.\n",
srv->id, other->conf.line);
err_code |= ERR_ALERT | ERR_FATAL;
goto out;
}
- if ((other = server_find_by_name(px, newsrv->id))) {
+ if ((other = server_find_by_name2(px, newsrv->id))) {
ha_alert("another server named '%s' was already defined at line %d, please use a distinct name.\n",
newsrv->id, other->conf.line);
err_code |= ERR_ALERT | ERR_FATAL;
goto out;
}
- if ((other = server_find_by_name(curproxy, newsrv->id))) {
+ if ((other = server_find_by_name2(curproxy, newsrv->id))) {
ha_alert("another server named '%s' was already defined at line %d, please use a distinct name.\n",
args[1], other->conf.line);
err_code |= ERR_ALERT | ERR_FATAL;
return cebuis_item_lookup(&px->conf.used_server_name, conf.name_node, id, name, struct server);
}
+/* Equivalent to server_find_by_name() excepts it also lookup in the named
+ * default-server tree.
+ */
+struct server *server_find_by_name2(struct proxy *px, const char *name)
+{
+ struct server *srv;
+
+ srv = server_find_by_name(px, name);
+ if (srv)
+ return srv;
+
+ return cebuis_item_lookup(&px->defsrv_by_name, conf.name_node, id, name,
+ struct server);
+}
+
/*
* This function returns the server with a matching address within selected
* proxy, or NULL if not found. The proxy lock is taken for reads during this
/* re-check for name conflict under isolation — another rename or
* add server could have raced before we isolated.
*/
- if (server_find_by_name(be, new_name)) {
+ if (server_find_by_name2(be, new_name)) {
thread_release();
free(dup);
return "A server with the same name already exists in this backend.\n";
/*
* If a server with the same name is found, reject the new one.
*/
- if (server_find(be, sv_name)) {
+ if (server_find_by_name2(be, sv_name)) {
thread_release();
cli_err(appctx, "Already exists a server with the same name in backend.\n");
return 1;