save works

This commit is contained in:
Rongsong Shen 2026-03-04 18:18:53 +08:00
parent acfbec875b
commit 3f74f14687
38 changed files with 751 additions and 448 deletions

View file

@ -17,12 +17,12 @@
#include "xce/types.h"
#include "jobj.h"
#include "resobj.h"
#include "utils.h"
#include "worker.h"
#include "xce/errnox.h"
#include "xstring.h"
#include "jobj.h"
static xce_peerinfo_t from_controller
= { .name = "controller", .key = "keepSecret" };
@ -376,6 +376,14 @@ int cluster_build_resources(cluster_t* c)
if (res == NULL) {
return -errno;
}
if ((res->flags & XCE_RESF_GLOBAL) != 0) {
res->idx = c->n_shared_res;
c->n_shared_res++;
} else {
res->idx = c->n_host_res;
c->n_host_res++;
}
}
return 0;
@ -509,25 +517,20 @@ int cluster_init(cluster_t* c)
SSL_CTX* ssl_ctx = NULL;
kvmgr_params_t config_mgr_params
= { .key_type = KVMGR_KEY_STRING,
.dynamic = 1,
.nslots = 128,
.delta = 128,
.datakiller = (destroy_fn_t)config_obj_killer };
kvmgr_params_t resmgr_params
= { .key_type = KVMGR_KEY_STRING,
.dynamic = 1,
.datakiller = (destroy_fn_t)res_obj_killer };
kvmgr_params_t jobmgr_params
= { .key_type = KVMGR_KEY_INT,
.dynamic = 1,
.datakiller = (destroy_fn_t)job_obj_killer };
kvmgr_params_t workermgr_params
= { .key_type = KVMGR_KEY_STRING,
.dynamic = 1,
.datakiller = (destroy_fn_t)worker_obj_killer };
kvmgr_params_t qmgr_params
= { .key_type = KVMGR_KEY_STRING,
.dynamic = 0,
.datakiller = (destroy_fn_t)queue_obj_killer };
if (c == NULL) {
@ -681,9 +684,17 @@ static int check_workers_timeout(void* args)
iterator_t it;
cluster_t* c = (cluster_t*)args;
int rc = 0;
xlist_t l;
int i;
xlist_init(&l, 1024);
lock(c->workermgr, RTTI_LOCK_READ);
rc = iter_make(&it, c->workermgr);
if (rc < 0) {
unlock(c->workermgr);
xlist_fini(&l);
return rc;
}
@ -695,7 +706,12 @@ static int check_workers_timeout(void* args)
break;
}
check_worker_timeout_(c, w);
/* check_worker_timeout_(c, w); */
if (w != NULL) {
reference(w);
xlist_store(&l, w);
}
}
if (rc == RTTI_ITER_NO_DATA) {
@ -703,6 +719,23 @@ static int check_workers_timeout(void* args)
}
iter_destroy(&it);
unlock(c->workermgr);
for (i = 0; i < l.count; i++) {
worker_t* w = xlist_get(&l, i);
if (w == NULL) {
continue;
}
lock(w, RTTI_LOCK_WRITE);
check_worker_timeout_(c, w);
unlock(w);
dereference(w);
}
xlist_fini(&l);
return rc;
}
@ -781,7 +814,7 @@ void cluster_fini(cluster_t* c)
cleanup_openssl();
job_obj_fini();
xstring_table_fini();
return;