Skip to content
Snippets Groups Projects
Commit 830419d8 authored by Christopher J. Morrone's avatar Christopher J. Morrone
Browse files

Intialize the struct fed_nodinfo table_size to 0. This fixes

a bug when the network string does not contain "us" and the
normal federation table setup is skipped.

Add extra malloc return code checking and cleanup in fed_copy_jobinfo.
parent fb16a952
No related branches found
No related tags found
No related merge requests found
...@@ -498,6 +498,9 @@ fed_alloc_jobinfo(fed_jobinfo_t **j) ...@@ -498,6 +498,9 @@ fed_alloc_jobinfo(fed_jobinfo_t **j)
if (!new) if (!new)
slurm_seterrno_ret(ENOMEM); slurm_seterrno_ret(ENOMEM);
new->magic = FED_JOBINFO_MAGIC; new->magic = FED_JOBINFO_MAGIC;
new->job_key = -1;
new->window_memory = 0;
new->table_size = 0;
new->table = NULL; new->table = NULL;
new->lid_index = NULL; new->lid_index = NULL;
*j = new; *j = new;
...@@ -1485,28 +1488,59 @@ fed_jobinfo_t * ...@@ -1485,28 +1488,59 @@ fed_jobinfo_t *
fed_copy_jobinfo(fed_jobinfo_t *j) fed_copy_jobinfo(fed_jobinfo_t *j)
{ {
fed_jobinfo_t *new; fed_jobinfo_t *new;
NTBL **tmp;
int i; int i;
if(fed_alloc_jobinfo(&new)) assert(j);
return NULL; assert(j->magic == FED_JOBINFO_MAGIC);
memcpy(new, j, sizeof(fed_jobinfo_t));
new->lid_index = (char *)malloc(new->table_size * FED_ADAPTERLEN); if(fed_alloc_jobinfo(&new)) {
tmp = (NTBL **)malloc(sizeof(NTBL *) * new->table_size); debug("fed_alloc_jobinfo failed");
if((tmp == NULL) || (new->lid_index == NULL)) { goto cleanup1;
fed_free_jobinfo(new);
slurm_seterrno(ENOMEM);
return NULL;
} }
for(i = 0; i < new->table_size; i++) { memcpy(new, j, sizeof(fed_jobinfo_t));
tmp[i] = (NTBL *)malloc(sizeof(NTBL)); /* table will be empty (and table_size == 0) when the network string
memcpy(tmp[i], j->table[i], sizeof(NTBL)); * from poe does not contain "us".
* (See man poe: -euilib or MP_EUILIB)
*/
if (new->table_size > 0) {
int size;
size = new->table_size * FED_ADAPTERLEN;
new->lid_index = (char *)malloc(size);
if (new->lid_index == NULL) {
debug("fed_copy_jobinfo new->lid_index malloc failed");
goto cleanup2;
}
memcpy(new->lid_index, j->lid_index, size);
size = sizeof(NTBL *) * new->table_size;
new->table = (NTBL **)malloc(size);
if (new->table == NULL) {
debug("fed_copy_jobinfo: new->table malloc failed");
goto cleanup3;
}
memset(new->table, 0, size);
for(i = 0; i < new->table_size; i++) {
new->table[i] = (NTBL *)malloc(sizeof(NTBL));
if (new->table[i] == NULL)
goto cleanup4;
memcpy(new->table[i], j->table[i], sizeof(NTBL));
}
} }
new->table = tmp; return new;
memcpy(new->lid_index, j->lid_index, new->table_size * FED_ADAPTERLEN);
cleanup4:
return new; for (i = 0; i < new->table_size; i++)
if (new->table[i])
free(new->table[i]);
cleanup3:
free(new->lid_index);
cleanup2:
fed_free_jobinfo(new);
cleanup1:
slurm_seterrno(ENOMEM);
return NULL;
} }
/* Used by: all */ /* Used by: all */
...@@ -1523,6 +1557,7 @@ fed_free_jobinfo(fed_jobinfo_t *jp) ...@@ -1523,6 +1557,7 @@ fed_free_jobinfo(fed_jobinfo_t *jp)
if(!jp->table[i]) if(!jp->table[i])
free(jp->table[i]); free(jp->table[i]);
} }
free(jp->table);
} }
if(jp->lid_index) if(jp->lid_index)
free(jp->lid_index); free(jp->lid_index);
......
...@@ -236,6 +236,9 @@ int switch_p_libstate_restore ( char * dir_name ) ...@@ -236,6 +236,9 @@ int switch_p_libstate_restore ( char * dir_name )
* notification of this will be forwarded to slurmctld. We do not * notification of this will be forwarded to slurmctld. We do not
* enforce that in this function. * enforce that in this function.
*/ */
/* FIX ME! - should use adapter name from federation.conf file now that
* we have that file support.
*/
#define ZERO 48 #define ZERO 48
int switch_p_clear_node_state(void) int switch_p_clear_node_state(void)
{ {
...@@ -331,6 +334,8 @@ switch_jobinfo_t switch_p_copy_jobinfo(switch_jobinfo_t switch_job) ...@@ -331,6 +334,8 @@ switch_jobinfo_t switch_p_copy_jobinfo(switch_jobinfo_t switch_job)
switch_jobinfo_t j; switch_jobinfo_t j;
j = (switch_jobinfo_t)fed_copy_jobinfo((fed_jobinfo_t *)switch_job); j = (switch_jobinfo_t)fed_copy_jobinfo((fed_jobinfo_t *)switch_job);
if (!j)
error("fed_copy_jobinfo failed");
return j; return j;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment