Until now, every form of "this server is referenced by something in the
running config" was collapsed onto a single flag, SRV_F_NON_PURGEABLE,
which prevents the server from being removed via 'del server'. This
catches everything but conflates two distinct properties:
- the server object itself is pinned by another runtime structure
(e.g. DNS resolution attached to it), versus
- the server's *name* is referenced statically (use-server rules,
track chains, sample-fetch arguments of type ARGT_SRV)
These differ for any operation that touches the name but not the
object identity, e.g. the runtime rename feature added next. Removing
a name-referenced server is still forbidden (the rule text would
dangle), but renaming such a server should also be forbidden for the
same reason - while renaming a resolver-pinned server is fine, since
the resolver holds the object pointer and doesn't care about the name.
Introduce SRV_F_NAME_REFD for the name-reference case and move the
three name-based setters (sample.c ARGT_SRV resolution, proxy.c
use-server resolution, server.c track chain setup) from
SRV_F_NON_PURGEABLE to SRV_F_NAME_REFD. The resolvers.c call site
keeps SRV_F_NON_PURGEABLE since it is the object-pinned case.
Adjust 'del server' to check both flags so the set of servers it
refuses to remove is unchanged: same observable behavior, just a
richer internal taxonomy.
A subsequent patch introducing 'set server name' will gate on
SRV_F_NAME_REFD only.
#define SRV_F_STRICT_MAXCONN 0x10000 /* maxconn is to be strictly enforced, as a limit of outbound connections */
#define SRV_F_CHK_NO_AUTO_SNI 0x20000 /* disable automatic SNI selection for healthcheck */
#define SRV_F_UDP_GSO_NOTSUPP 0x40000 /* UDP GSO is disabled due to a previous error encountered */
+#define SRV_F_NAME_REFD 0x80000 /* this server's name is statically referenced (use-server, track, sample arg) */
/* configured server options for send-proxy (server->pp_opts) */
#define SRV_PP_V1 0x0001 /* proxy protocol version 1 */
}
ha_free(&srule->srv.name);
srule->srv.ptr = target;
- target->flags |= SRV_F_NON_PURGEABLE;
+ target->flags |= SRV_F_NAME_REFD;
}
/* find the target table for 'stick' rules */
}
/* TODO CLI set-var should not prevent server deletion as var value is instantly resolved. */
- srv->flags |= SRV_F_NON_PURGEABLE;
+ srv->flags |= SRV_F_NAME_REFD;
chunk_destroy(&arg->data.str);
arg->unresolved = 0;
goto leave;
}
- if (srv->flags & SRV_F_NON_PURGEABLE) {
+ if (srv->flags & (SRV_F_NON_PURGEABLE | SRV_F_NAME_REFD)) {
msg = "This server cannot be removed at runtime due to other configuration elements pointing to it.";
goto leave;
}
srv->track = strack;
srv->tracknext = strack->trackers;
strack->trackers = srv;
- strack->flags |= SRV_F_NON_PURGEABLE;
+ strack->flags |= SRV_F_NAME_REFD;
ha_free(&srv->trackit);