1
1

More cleanup of pointer array usage

This commit was SVN r20981.
Этот коммит содержится в:
Ralph Castain 2009-04-13 19:06:54 +00:00
родитель cd512599bf
Коммит 9f7c605166
2 изменённых файлов: 10 добавлений и 21 удалений

Просмотреть файл

@ -410,26 +410,22 @@ int orte_dt_init(void)
orte_job_t* orte_get_job_data_object(orte_jobid_t job)
{
orte_job_t **jptr;
orte_std_cntr_t i;
int32_t ljob;
/* if I am not an HNP, I cannot provide this object */
if (!orte_process_info.hnp) {
return NULL;
}
jptr = (orte_job_t**)orte_job_data->addr;
for (i=0; i < orte_job_data->size; i++) {
if (NULL != jptr[i] && job == jptr[i]->jobid) {
return jptr[i];
}
}
/* not an error for this to not be found - could just be
/* the job is indexed by its local jobid, so we can
* just look it up here. it is not an error for this
* to not be found - could just be
* a race condition whereby the job has already been
* removed from the array. So just return NULL
* removed from the array. The get_item function
* will just return NULL in that case.
*/
return NULL;
ljob = ORTE_LOCAL_JOBID(job);
return (orte_job_t*)opal_pointer_array_get_item(orte_job_data, ljob);
}

Просмотреть файл

@ -819,28 +819,21 @@ int orte_util_encode_pidmap(opal_byte_object_t *boptr)
opal_buffer_t buf;
orte_local_rank_t *lrank;
orte_node_rank_t *nrank;
orte_job_t **jobs, *jdata;
orte_job_t *jdata;
int j;
int rc;
/* setup the working buffer */
OBJ_CONSTRUCT(&buf, opal_buffer_t);
jobs = (orte_job_t**)orte_job_data->addr;
/* unfortunately, job objects cannot be stored
* by index number as the jobid is a constructed
* value. So we have no choice but to cycle through
* the job pointer array and look at each entry
*/
for (j=1; j < orte_job_data->size; j++) {
/* the job array is no longer left-justified and may
* have holes in it as we recover resources at job
* completion
*/
if (NULL == jobs[j]) {
if (NULL == (jdata = (orte_job_t*)opal_pointer_array_get_item(orte_job_data, j))) {
continue;
}
jdata = jobs[j];
/* pack the jobid */
if (ORTE_SUCCESS != (rc = opal_dss.pack(&buf, &jdata->jobid, 1, ORTE_JOBID))) {
ORTE_ERROR_LOG(rc);