#include <haproxy/connection-t.h>
#include <haproxy/counters-t.h>
#include <haproxy/freq_ctr-t.h>
+#include <haproxy/guid-t.h>
#include <haproxy/listener-t.h>
#include <haproxy/obj_type-t.h>
#include <haproxy/queue-t.h>
event_hdl_sub_list e_subs; /* event_hdl: server's subscribers list (atomically updated) */
+ struct guid_node guid; /* GUID global tree node */
+
/* warning, these structs are huge, keep them at the bottom */
struct conn_src conn_src; /* connection source settings */
struct sockaddr_storage addr; /* the address to connect to, doesn't include the port */
#include <import/ebistree.h>
#include <haproxy/obj_type.h>
#include <haproxy/proxy.h>
+#include <haproxy/server-t.h>
#include <haproxy/tools.h>
/* GUID global tree */
guid = &__objt_proxy(objt)->guid;
break;
+ case OBJ_TYPE_SERVER:
+ guid = &__objt_server(objt)->guid;
+ break;
+
default:
/* No guid support for this objtype. */
ABORT_NOW();
{
char *msg = NULL;
struct proxy *px;
+ struct server *srv;
switch (obj_type(guid->obj_type)) {
case OBJ_TYPE_PROXY:
px = __objt_proxy(guid->obj_type);
return memprintf(&msg, "%s %s", proxy_cap_str(px->cap), px->id);
+ case OBJ_TYPE_SERVER:
+ srv = __objt_server(guid->obj_type);
+ return memprintf(&msg, "server %s/%s", srv->proxy->id, srv->id);
+
default:
break;
}
#include <haproxy/dict-t.h>
#include <haproxy/errors.h>
#include <haproxy/global.h>
+#include <haproxy/guid.h>
#include <haproxy/log.h>
#include <haproxy/mailers.h>
#include <haproxy/namespace.h>
return 0;
}
+/* Parse the "guid" keyword */
+static int srv_parse_guid(char **args, int *cur_arg,
+ struct proxy *curproxy, struct server *newsrv, char **err)
+{
+ const char *guid;
+ char *guid_err = NULL;
+
+ if (!*args[*cur_arg + 1]) {
+ memprintf(err, "'%s' : expects an argument", args[*cur_arg]);
+ return ERR_ALERT | ERR_FATAL;
+ }
+
+ guid = args[*cur_arg + 1];
+ if (guid_insert(&newsrv->obj_type, guid, &guid_err)) {
+ memprintf(err, "'%s': %s", args[*cur_arg], guid_err);
+ ha_free(&guid_err);
+ return ERR_ALERT | ERR_FATAL;
+ }
+
+ return 0;
+}
+
/* Parse the "ws" keyword */
static int srv_parse_ws(char **args, int *cur_arg,
struct proxy *curproxy, struct server *newsrv, char **err)
{ "disabled", srv_parse_disabled, 0, 1, 1 }, /* Start the server in 'disabled' state */
{ "enabled", srv_parse_enabled, 0, 1, 0 }, /* Start the server in 'enabled' state */
{ "error-limit", srv_parse_error_limit, 1, 1, 1 }, /* Configure the consecutive count of check failures to consider a server on error */
+ { "guid", srv_parse_guid, 1, 0, 1 }, /* Set global unique ID of the server */
{ "ws", srv_parse_ws, 1, 1, 1 }, /* websocket protocol */
{ "hash-key", srv_parse_hash_key, 1, 1, 1 }, /* Configure how chash keys are computed */
{ "id", srv_parse_id, 1, 0, 1 }, /* set id# of server */
MT_LIST_INIT(&srv->sess_conns);
+ guid_init(&srv->guid);
+
srv->extra_counters = NULL;
#ifdef USE_OPENSSL
HA_RWLOCK_INIT(&srv->ssl_ctx.lock);
if (HA_ATOMIC_SUB_FETCH(&srv->refcount, 1))
goto end;
+ guid_remove(&srv->guid);
+
/* make sure we are removed from our 'next->prev_deleted' list
* This doesn't require full thread isolation as we're using mt lists
* However this could easily be turned into regular list if required