/* * extres.c — connected extres daemons (HostRole_extres joins) * * external-license-resources Phase 1: the external-resources daemon * (xceesd) joins the controller with HostRole_extres and pushes * cluster-level (SHARED) resource values through the ordinary resval * update pipeline (opupd.c do_update_resvals). Mirrors the apiserver * join/leave registration in apiserver.c: endpoint + name only, no * workermgr slot — the daemon is not a schedulable host. The controller * never pushes TO the daemon; the daemon re-pushes its full value set on * every (re)connect, so nothing here needs replay/WAL treatment. */ #include #include #include #include "cluster.h" #include "xstring.h" #include "xce/cluster_def.h" int add_extres(cluster_t* c, char* name, endpoint_t* ep) { int i; for (i = 0; i < N_EXTRES_MAX; i++) { if ((c->extresds[i].name != NULL) && (strcmp(c->extresds[i].name, name) == 0)) { /* re-join (reconnect or failover re-join): rebind in place */ c->extresds[i].ep = ep; return i; } } for (i = 0; i < N_EXTRES_MAX; i++) { if (c->extresds[i].name == NULL) { c->extresds[i].name = makeString(name); if (c->extresds[i].name == NULL) { return -ENOMEM; } c->extresds[i].ep = ep; return i; } } ERROR("too many extres daemons (max %d); join from %s refused", N_EXTRES_MAX, name); return -ENOSPC; } int handle_extres_leave(cluster_t* c, endpoint_t* ep) { ep_private_t* priv; int i; if (ep == NULL) { return -EINVAL; } priv = (ep_private_t*)ep->data; if (priv == NULL) { return -EINVAL; } i = priv->u.idx; if ((i < 0) || (i >= N_EXTRES_MAX)) { SET_ERROR(EINVAL); return -errno; } /* Only clear if it is still our binding — a re-join may have rebound * the slot to a new endpoint before this old one's close event ran. */ if (c->extresds[i].ep == ep) { c->extresds[i].ep = NULL; } return 0; }