diff --git a/src/slurmd/job.c b/src/slurmd/job.c index a66a64acc03c99920b5c866ff1acf1f36ee06501..9891a2dbbdeeb44572a1abcdd09efd78b786bbb6 100644 --- a/src/slurmd/job.c +++ b/src/slurmd/job.c @@ -46,6 +46,7 @@ #include "src/slurmd/shm.h" #include "src/slurmd/io.h" #include "src/slurmd/fname.h" +#include "src/slurmd/slurmd.h" static char ** _array_copy(int n, char **src); static void _array_free(int n, char ***array); @@ -389,7 +390,7 @@ job_update_shm(slurmd_job_t *job) s.stepid = job->stepid; s.ntasks = job->ntasks; s.timelimit = job->timelimit; - + strncpy(s.exec_name, job->argv[0], MAXPATHLEN); s.sw_id = 0; if (shm_insert_step(&s) < 0) diff --git a/src/slurmd/mgr.c b/src/slurmd/mgr.c index 1f266e3e17312e2a530f4d4d09eaa75defcfbcea..06ae078348cc1f9fe5a068dfcfff1f0d65837436 100644 --- a/src/slurmd/mgr.c +++ b/src/slurmd/mgr.c @@ -264,7 +264,7 @@ mgr_launch_batch_job(batch_job_launch_msg_t *msg, slurm_addr *cli) if ((batchdir = _make_batch_dir(job)) == NULL) goto cleanup2; - FREE_NULL(job->argv[0]); + xfree(job->argv[0]); if ((job->argv[0] = _make_batch_script(msg, batchdir)) == NULL) goto cleanup3; diff --git a/src/slurmd/req.c b/src/slurmd/req.c index a3bbb18953f8fdef789c157698b797edaa420109..c2ef98e31b9a39b033257e710e33cdfb3dd1b5a1 100644 --- a/src/slurmd/req.c +++ b/src/slurmd/req.c @@ -38,6 +38,7 @@ #include "src/common/log.h" #include "src/common/slurm_auth.h" #include "src/common/slurm_protocol_api.h" +#include "src/common/xstring.h" #include "src/common/xmalloc.h" #include "src/slurmd/slurmd.h" @@ -470,6 +471,7 @@ _rpc_reattach_tasks(slurm_msg_t *msg, slurm_addr *cli) resp.gids[t->id] = t->global_id; resp.local_pids[t->id] = t->pid; } + resp.executable_name = xstrdup(step->exec_name); shm_free_step(step); @@ -480,12 +482,11 @@ _rpc_reattach_tasks(slurm_msg_t *msg, slurm_addr *cli) resp.node_name = conf->hostname; resp.srun_node_id = req->srun_node_id; resp.return_code = rc; - resp.executable_name ="TBD"; /* job->argv[0]; */ slurm_send_only_node_msg(&resp_msg); - FREE_NULL(resp.gids); - FREE_NULL(resp.local_pids); + xfree(resp.gids); + xfree(resp.local_pids); } diff --git a/src/slurmd/shm.c b/src/slurmd/shm.c index 500640f6e02869c81411beef97d5dd96eacb5327..1db81f5dd2be8573485608b5f437c4887168dab4 100644 --- a/src/slurmd/shm.c +++ b/src/slurmd/shm.c @@ -63,6 +63,7 @@ #include "src/common/xmalloc.h" #include "src/common/xassert.h" #include "src/common/slurm_errno.h" +#include "src/common/xstring.h" #include "src/slurmd/slurmd.h" #include "src/slurmd/shm.h" @@ -575,7 +576,8 @@ shm_update_step_addrs(uint32_t jobid, uint32_t stepid, memcpy(s->key.data, keydata, SLURM_KEY_SIZE); s->io_update = true; - debug3("Going to send shm update signal to %ld", s->sid); + debug3("Going to send shm update signal to %ld", + s->sid); if (kill(s->sid, SIGHUP) < 0) { slurm_seterrno(EPERM); retval = SLURM_FAILURE; @@ -770,7 +772,7 @@ _shm_task_copy(task_t *to, task_t *from) static void _shm_step_copy(job_step_t *to, job_step_t *from) { - *to = *from; + memcpy(to, from, sizeof(job_step_t)); to->state = SLURMD_JOB_ALLOCATED; /* addition of tasks is another step */ @@ -780,14 +782,15 @@ _shm_step_copy(job_step_t *to, job_step_t *from) static void _shm_clear_task(task_t *t) { - memset(t, 0, sizeof(*t)); + memset(t, 0, sizeof(task_t)); } static void _shm_clear_step(job_step_t *s) { task_t *p, *t = _taskp(s->task_list); - memset(s, 0, sizeof(*s)); + + memset(s, 0, sizeof(job_step_t)); if (!t) return; do { diff --git a/src/slurmd/shm.h b/src/slurmd/shm.h index 36ff999b0618d8ab25ffe942cee29e68330bf55c..ffe388a11568b5d112180cf0f0b44f343a31fa2b 100644 --- a/src/slurmd/shm.h +++ b/src/slurmd/shm.h @@ -47,6 +47,8 @@ # include <unistd.h> #endif +#include <sys/param.h> /* MAXPATHLEN */ + #include "src/common/slurm_protocol_api.h" #include "src/common/list.h" @@ -84,6 +86,7 @@ struct job_step { uint32_t sw_id; /* Switch/Interconnect specific id */ int ntasks; /* number of tasks in this job */ pid_t sid; /* Job session id */ + char exec_name[MAXPATHLEN]; /* Executable's pathname */ int io_update; /* srun address has been updated */ slurm_addr respaddr; /* Addr to send messages to srun on */ diff --git a/src/slurmd/slurmd.h b/src/slurmd/slurmd.h index 0a87f054ef1582d4311af5ccf9db9d4a31dc4993..ffdb52a378c5986bb076851cec3d3ca89be7fc14 100644 --- a/src/slurmd/slurmd.h +++ b/src/slurmd/slurmd.h @@ -51,12 +51,6 @@ extern pid_t getsid(pid_t pid); /* missing from <unistd.h> */ #endif -#define FREE_NULL(_X) \ - do { \ - if (_X) xfree (_X); \ - _X = NULL; \ - } while (0) - /* * Global config type