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,7 +17,12 @@ static int run_tasks_on_host(cluster_t* c, endpoint_t* ep, uint64_t jobid,
.clientidx = ep->idx,
.taskhosts = (xce_taskhost_t*[]) { info } };
lock(c->workermgr, RTTI_LOCK_READ);
rc = key_find(c->workermgr, (void*)info->host, (void**)&w);
if (w != NULL) {
reference(w);
}
unlock(c->workermgr);
if (rc < 0) {
return rc;
}
@ -27,10 +32,13 @@ static int run_tasks_on_host(cluster_t* c, endpoint_t* ep, uint64_t jobid,
}
if ((w->ep == NULL) || (IS_WORKER_UNAVAIL(w->host.status))) {
dereference(w);
return -EINVAL;
}
rc = xce_runtask_req(w->ep, &runmsg);
dereference(w);
return rc;
}
@ -43,8 +51,14 @@ static int check_task_hosts(cluster_t* c, xce_taskrun_t* runmsg)
worker_t* w;
int rc = 0;
lock(c->workermgr, RTTI_LOCK_READ);
rc = key_find(c->workermgr, (void*)runmsg->taskhosts[i]->host,
(void**)&w);
if (w != NULL) {
reference(w);
}
unlock(c->workermgr);
if (rc < 0) {
return rc;
}
@ -57,8 +71,12 @@ static int check_task_hosts(cluster_t* c, xce_taskrun_t* runmsg)
}
if ((w->ep == NULL) || IS_WORKER_UNAVAIL(w->host.status)) {
dereference(w);
return -ENOENT;
}
dereference(w);
}
return 0;