fix memory leak
This commit is contained in:
parent
cf1dbdc07a
commit
e001d4955c
3 changed files with 48 additions and 68 deletions
|
|
@ -410,8 +410,9 @@ int handle_jobdispatch(cluster_t* c, endpoint_t* ep, xce_request_t* request)
|
||||||
} else {
|
} else {
|
||||||
/* notify dispatch ok */
|
/* notify dispatch ok */
|
||||||
notify_dispatch(c, ep, alloc->jobid, 0);
|
notify_dispatch(c, ep, alloc->jobid, 0);
|
||||||
free_JobAlloc_ptr(&(alloc));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
free_JobAlloc_ptr(&(alloc));
|
||||||
}
|
}
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@
|
||||||
#include <readline/readline.h>
|
#include <readline/readline.h>
|
||||||
|
|
||||||
#include <cjson/cJSON.h>
|
#include <cjson/cJSON.h>
|
||||||
|
#include <cjson/s2j.h>
|
||||||
|
|
||||||
#include "client.h"
|
#include "client.h"
|
||||||
#include "controller.capnp.h"
|
#include "controller.capnp.h"
|
||||||
|
|
@ -60,11 +61,25 @@ typedef struct {
|
||||||
int ntasks;
|
int ntasks;
|
||||||
} host_task_t;
|
} host_task_t;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
char* PATH;
|
||||||
|
} sub_envs_t;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
sub_envs_t sub_env_vars;
|
||||||
|
} exdata_t;
|
||||||
|
|
||||||
#define MAX_RUN_JOBS (20)
|
#define MAX_RUN_JOBS (20)
|
||||||
#define MAX_TASK_HOSTS (5)
|
#define MAX_TASK_HOSTS (5)
|
||||||
#define MAX_RUN_TASKS (50)
|
#define MAX_RUN_TASKS (50)
|
||||||
#define RUSAGE_UPDATE_INTERVAL (60)
|
#define RUSAGE_UPDATE_INTERVAL (60)
|
||||||
|
|
||||||
|
#define S2J_JSON_SET_var_string_ELEMENT(to_json, from_struct, _element) \
|
||||||
|
if (((from_struct) != NULL) && (((from_struct)->_element) != NULL)) { \
|
||||||
|
cJSON_AddStringToObject((to_json), #_element, \
|
||||||
|
(from_struct)->_element); \
|
||||||
|
}
|
||||||
|
|
||||||
static run_job_t run_jobs[MAX_RUN_JOBS];
|
static run_job_t run_jobs[MAX_RUN_JOBS];
|
||||||
static run_task_t run_tasks[MAX_RUN_TASKS];
|
static run_task_t run_tasks[MAX_RUN_TASKS];
|
||||||
|
|
||||||
|
|
@ -767,41 +782,16 @@ int cmd_jobrun(int argc, char* argv[])
|
||||||
|
|
||||||
static int build_job_envs(xce_job_submit_t* submit)
|
static int build_job_envs(xce_job_submit_t* submit)
|
||||||
{
|
{
|
||||||
char* names[] = { "PATH", "LSAN_OPTIONS", NULL };
|
exdata_t exdata = { .sub_env_vars = { .PATH = getenv("PATH") } };
|
||||||
int i;
|
|
||||||
cJSON* top;
|
|
||||||
cJSON* envars;
|
|
||||||
char* exdata;
|
|
||||||
|
|
||||||
top = cJSON_CreateObject();
|
s2j_create_json_obj(json_exdata);
|
||||||
if (top == NULL) {
|
s2j_create_json_obj(json_envs);
|
||||||
return -1;
|
s2j_json_set_basic_element(json_envs, &(exdata.sub_env_vars), var_string,
|
||||||
}
|
PATH);
|
||||||
|
cJSON_AddItemToObject(json_exdata, "sub_env_vars", json_envs);
|
||||||
|
|
||||||
envars = cJSON_CreateObject();
|
submit->submit->start_info->exdata = cJSON_Print(json_exdata);
|
||||||
if (envars == NULL) {
|
cJSON_Delete(json_exdata);
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
cJSON_AddItemToObject(top, "sub_env_vars", envars);
|
|
||||||
|
|
||||||
for (i = 0; names[i] != NULL; i++) {
|
|
||||||
cJSON* val;
|
|
||||||
char* s = getenv(names[i]);
|
|
||||||
|
|
||||||
if (s == NULL) {
|
|
||||||
s = "";
|
|
||||||
}
|
|
||||||
|
|
||||||
val = cJSON_CreateString(s);
|
|
||||||
cJSON_AddItemToObject(envars, names[i], val);
|
|
||||||
}
|
|
||||||
|
|
||||||
exdata = cJSON_Print(top);
|
|
||||||
|
|
||||||
submit->submit->start_info->exdata = exdata;
|
|
||||||
|
|
||||||
cJSON_Delete(top);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -250,12 +250,28 @@ void job_obj_killer(job_t* job)
|
||||||
}
|
}
|
||||||
|
|
||||||
obj = TO_MYOBJ(job);
|
obj = TO_MYOBJ(job);
|
||||||
DEREF_OBJ(job->job.submit->queue);
|
if (job->job.submit != NULL) {
|
||||||
DEREF_OBJ(job->job.submit->user);
|
DEREF_OBJ(job->job.submit->queue);
|
||||||
DEREF_OBJ(job->job.submit->job_name);
|
DEREF_OBJ(job->job.submit->user);
|
||||||
DEREF_OBJ(job->job.submit->project_name);
|
DEREF_OBJ(job->job.submit->job_name);
|
||||||
DEREF_OBJ(job->job.submit->job_description);
|
DEREF_OBJ(job->job.submit->project_name);
|
||||||
DEREF_OBJ(job->job.submit->resreq);
|
DEREF_OBJ(job->job.submit->job_description);
|
||||||
|
DEREF_OBJ(job->job.submit->resreq);
|
||||||
|
|
||||||
|
if (job->job.submit->start_info != NULL) {
|
||||||
|
DEREF_OBJ(job->job.submit->start_info->cmdline);
|
||||||
|
DEREF_OBJ(job->job.submit->start_info->exechome);
|
||||||
|
DEREF_OBJ(job->job.submit->start_info->execcwd);
|
||||||
|
DEREF_OBJ(job->job.submit->start_info->execuser);
|
||||||
|
DEREF_OBJ(job->job.submit->start_info->exdata);
|
||||||
|
DEREF_OBJ(job->job.submit->start_info->launch_type);
|
||||||
|
DEREF_OBJ(job->job.submit->start_info->job_pre_exec);
|
||||||
|
DEREF_OBJ(job->job.submit->start_info->job_post_exec);
|
||||||
|
FREEUP(job->job.submit->start_info);
|
||||||
|
}
|
||||||
|
|
||||||
|
FREEUP(job->job.submit);
|
||||||
|
}
|
||||||
|
|
||||||
if (job->job.pidinfo != NULL) {
|
if (job->job.pidinfo != NULL) {
|
||||||
FREEUP(job->job.pidinfo->pids);
|
FREEUP(job->job.pidinfo->pids);
|
||||||
|
|
@ -268,22 +284,7 @@ void job_obj_killer(job_t* job)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (job->job.allocs != NULL) {
|
if (job->job.allocs != NULL) {
|
||||||
for (int i = 0; i < job->job.allocs->nhosts; i++) {
|
free_JobAlloc_ptr(&(job->job.allocs));
|
||||||
FREEUP(job->job.allocs->allocs[i]->host);
|
|
||||||
for (int k = 0; k < job->job.allocs->allocs[i]->nallocs; k++) {
|
|
||||||
xce_alloc_t* alloc
|
|
||||||
= (xce_alloc_t*)job->job.allocs->allocs[i]->allocs[k];
|
|
||||||
if (alloc == NULL) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
FREEUP(alloc->resname);
|
|
||||||
FREEUP(alloc->reserve);
|
|
||||||
free(alloc);
|
|
||||||
}
|
|
||||||
FREEUP(job->job.allocs->allocs[i]);
|
|
||||||
}
|
|
||||||
FREEUP(job->job.allocs->allocs);
|
|
||||||
FREEUP(job->job.allocs);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (job->job.run_usage != NULL) {
|
if (job->job.run_usage != NULL) {
|
||||||
|
|
@ -295,18 +296,6 @@ void job_obj_killer(job_t* job)
|
||||||
FREEUP(job->job.run_usage);
|
FREEUP(job->job.run_usage);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (job->job.submit->start_info != NULL) {
|
|
||||||
DEREF_OBJ(job->job.submit->start_info->cmdline);
|
|
||||||
DEREF_OBJ(job->job.submit->start_info->exechome);
|
|
||||||
DEREF_OBJ(job->job.submit->start_info->execcwd);
|
|
||||||
DEREF_OBJ(job->job.submit->start_info->execuser);
|
|
||||||
DEREF_OBJ(job->job.submit->start_info->exdata);
|
|
||||||
DEREF_OBJ(job->job.submit->start_info->launch_type);
|
|
||||||
DEREF_OBJ(job->job.submit->start_info->job_pre_exec);
|
|
||||||
DEREF_OBJ(job->job.submit->start_info->job_post_exec);
|
|
||||||
FREEUP(job->job.submit->start_info);
|
|
||||||
}
|
|
||||||
|
|
||||||
FREEUP(job->job.exit_info);
|
FREEUP(job->job.exit_info);
|
||||||
|
|
||||||
memset(obj, 0x0, sizeof(*obj));
|
memset(obj, 0x0, sizeof(*obj));
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue