save works

This commit is contained in:
Rongsong Shen 2026-03-06 18:20:30 +08:00
parent 47fc32b02c
commit 43dc12a36c
19 changed files with 80 additions and 72 deletions

View file

@ -8,10 +8,10 @@
#include "jobj.h"
#include "kv.h"
#include "mylock.h"
#include "preason.h"
#include "utils.h"
#include "xce/types.h"
#include "xstring.h"
#include "preason.h"
static struct {
mylock_t lock;
@ -588,11 +588,11 @@ static void job_destroy(meta_obj_t* obj)
if (j->job.run_usage != NULL) {
int i;
for(i = 0; i < j->job.run_usage->num_hosts; i ++) {
for (i = 0; i < j->job.run_usage->num_hosts; i++) {
if (j->job.run_usage->host_runusage[i] != NULL) {
FREEUP(j->job.run_usage->host_runusage[i]->host_name);
}
FREEUP(j->job.run_usage->host_runusage[i]);
}

View file

@ -126,13 +126,15 @@ static xce_resource_t* makeResource_(var resmgr, xce_resource_t* r)
resobj = makeInstance(&resobj_type, r);
if (resobj != NULL) {
rc = key_add(resmgr, (void*)resobj->name, (void*)resobj);
if (rc < 0) {
destroy(resobj);
errno = -rc;
return NULL;
}
resobj->idx = rc;
}
return resobj;
}

View file

@ -75,6 +75,8 @@ int parse_section(xce_resreq_data_t* resreq, char* data, char** errmsg)
*errmsg = NULL;
ctx.input = data;
memset(resreq, 0x0, sizeof(*resreq));
p = xce_section_create(&ctx);
if (p == NULL) {
return -errno;

View file

@ -281,8 +281,6 @@ static void test_job_create(void)
&& (j2->job.submit->mintasks == 1) && (j2->job.submit->maxtasks == 5)
&& (j2->job.submit->user_group == NULL));
dereference(j2);
destroy(jobmgr);
job_obj_fini();

View file

@ -37,8 +37,6 @@ static void test_queue_create(void)
TEST_ASSERT_TRUE(q != NULL);
dereference(q);
destroy(qmgr);
xstring_table_fini();
}

View file

@ -52,7 +52,7 @@ void test_parse_section_fail(void)
"same[type] same[abcd] affinity[core(20)]";
char* errmsg = NULL;
int rc = 0;
xce_resreq_data_t data;
xce_resreq_data_t data = {0};
rc = parse_section(&data, (char*)resreq, &errmsg);
TEST_ASSERT_TRUE(rc < 0);

View file

@ -47,7 +47,6 @@ static void test_worker_create(void)
&& (w->host.attrs->cpufactor == attrs1.cpufactor)
&& (w->host.attrs->maxcpus == attrs1.maxcpus));
dereference(w);
destroy(workermgr);
xstring_table_fini();

View file

@ -305,10 +305,10 @@ int match_limit(xce_limit_t* limit, int global, ...)
int build_vres_name(char** vname, xce_limit_t* limit, char* user, char* queue,
char* project)
{
char resname[2 * XCE_MAXNAME_LEN + 1];
xce_consumer_t* c = NULL;
char* p = NULL;
int rc = 0;
size_t bufsize = 0;
FILE* fp = NULL;
xce_consumer_t* c = NULL;
int rc = 0;
*vname = NULL;
if ((vname == NULL) || (limit == NULL) || (user == NULL) || (queue == NULL)
@ -316,50 +316,33 @@ int build_vres_name(char** vname, xce_limit_t* limit, char* user, char* queue,
return -EINVAL;
}
memset(resname, 0x0, sizeof(resname));
p = &resname[0];
rc = sprintf(p, "limit=%s", limit->name);
if (rc < 0) {
return rc;
fp = open_memstream(vname, &bufsize);
if (fp == NULL) {
return -errno;
}
p += rc;
fprintf(fp, "limit=%s", limit->name);
c = limit->consumers[CONSUMER_USER];
if ((c != NULL) && (c->per_consumer == 1)) {
rc = sprintf(p, "/u=%s", user);
if (rc < 0) {
return rc;
}
p += rc;
fprintf(fp, "/u=%s", user);
}
c = limit->consumers[CONSUMER_QUEUE];
if ((c != NULL) && (c->per_consumer == 1)) {
rc = sprintf(p, "/q=%s", queue);
if (rc < 0) {
return rc;
}
p += rc;
fprintf(fp, "/q=%s", queue);
}
c = limit->consumers[CONSUMER_PROJECT];
if ((c != NULL) && (c->per_consumer == 1)) {
rc = sprintf(p, "/p=%s", project);
if (rc < 0) {
return rc;
}
p += rc;
fprintf(fp, "/p=%s", project);
}
*vname = strdup(resname);
fflush(fp);
fclose(fp);
if ((*vname) != NULL) {
return 1;
}

View file

@ -444,7 +444,10 @@ static int xzarray_ensure_items(xzarray_t* array, int mincap)
/* this will make we can get next free
* location quickly
*/
array->pos = array->caps;
if (array->data[array->pos].inuse) {
array->pos = array->caps;
}
array->caps = nc;
return 1;