Skip to content

Commit 3302864

Browse files
author
Ralph Castain
committed
Cleanup a typo that can cause a segfault - use a local variable name different than the one passed into the function
Signed-off-by: Ralph Castain <[email protected]>
1 parent 410befd commit 3302864

File tree

2 files changed

+37
-33
lines changed

2 files changed

+37
-33
lines changed

opal/mca/pmix/pmix2x/pmix/src/server/pmix_server_get.c

Lines changed: 36 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,6 @@ pmix_status_t pmix_server_get(pmix_buffer_t *buf,
297297
cbfunc(PMIX_ERR_NOT_FOUND, NULL, 0, cbdata, NULL, NULL);
298298
PMIX_INFO_FREE(info, ninfo);
299299
pmix_list_remove_item(&pmix_server_globals.local_reqs, &lcd->super);
300-
PMIX_LIST_DESTRUCT(&lcd->loc_reqs);
301300
PMIX_RELEASE(lcd);
302301
rc = PMIX_ERR_NOT_FOUND;
303302
}
@@ -542,46 +541,51 @@ static pmix_status_t _satisfy_request(pmix_nspace_t *nptr, pmix_rank_t rank,
542541
pmix_status_t pmix_pending_resolve(pmix_nspace_t *nptr, pmix_rank_t rank,
543542
pmix_status_t status, pmix_dmdx_local_t *lcd)
544543
{
545-
pmix_dmdx_local_t *cd;
544+
pmix_dmdx_local_t *cd, *ptr;
545+
pmix_dmdx_request_t *req;
546546

547547
/* find corresponding request (if exists) */
548-
if (NULL == lcd && NULL != nptr) {
549-
PMIX_LIST_FOREACH(cd, &pmix_server_globals.local_reqs, pmix_dmdx_local_t) {
550-
if (0 != strncmp(nptr->nspace, cd->proc.nspace, PMIX_MAX_NSLEN) ||
551-
rank != cd->proc.rank) {
552-
continue;
548+
if (NULL == lcd) {
549+
ptr = NULL;
550+
if (NULL != nptr) {
551+
PMIX_LIST_FOREACH(cd, &pmix_server_globals.local_reqs, pmix_dmdx_local_t) {
552+
if (0 != strncmp(nptr->nspace, cd->proc.nspace, PMIX_MAX_NSLEN) ||
553+
rank != cd->proc.rank) {
554+
continue;
555+
}
556+
ptr = cd;
557+
break;
553558
}
554-
lcd = cd;
555-
break;
556559
}
560+
if (NULL == ptr) {
561+
return PMIX_SUCCESS;
562+
}
563+
} else {
564+
ptr = lcd;
557565
}
558566

559-
/* If somebody was interested in this rank */
560-
if (NULL != lcd) {
561-
pmix_dmdx_request_t *req;
562-
563-
if (PMIX_SUCCESS != status){
564-
/* if we've got an error for this request - just forward it*/
565-
PMIX_LIST_FOREACH(req, &lcd->loc_reqs, pmix_dmdx_request_t) {
566-
/* if we can't satisfy this request - respond with error */
567-
req->cbfunc(status, NULL, 0, req->cbdata, NULL, NULL);
568-
}
569-
} else if (NULL != nptr) {
570-
/* if we've got the blob - try to satisfy requests */
571-
/* run through all the requests to this rank */
572-
PMIX_LIST_FOREACH(req, &lcd->loc_reqs, pmix_dmdx_request_t) {
573-
pmix_status_t rc;
574-
rc = _satisfy_request(nptr, rank, NULL, req->cbfunc, req->cbdata, NULL);
575-
if( PMIX_SUCCESS != rc ){
576-
/* if we can't satisfy this particular request (missing key?) */
577-
req->cbfunc(rc, NULL, 0, req->cbdata, NULL, NULL);
578-
}
567+
/* somebody was interested in this rank */
568+
if (PMIX_SUCCESS != status){
569+
/* if we've got an error for this request - just forward it*/
570+
PMIX_LIST_FOREACH(req, &ptr->loc_reqs, pmix_dmdx_request_t) {
571+
req->cbfunc(status, NULL, 0, req->cbdata, NULL, NULL);
572+
}
573+
} else if (NULL != nptr) {
574+
/* if we've got the blob - try to satisfy requests */
575+
/* run through all the requests to this rank */
576+
PMIX_LIST_FOREACH(req, &ptr->loc_reqs, pmix_dmdx_request_t) {
577+
pmix_status_t rc;
578+
rc = _satisfy_request(nptr, rank, NULL, req->cbfunc, req->cbdata, NULL);
579+
if( PMIX_SUCCESS != rc ){
580+
/* if we can't satisfy this particular request (missing key?) */
581+
req->cbfunc(rc, NULL, 0, req->cbdata, NULL, NULL);
579582
}
580583
}
581-
/* remove all requests to this rank and cleanup the corresponding structure */
582-
pmix_list_remove_item(&pmix_server_globals.local_reqs, (pmix_list_item_t*)lcd);
583-
PMIX_RELEASE(lcd);
584584
}
585+
/* remove all requests to this rank and cleanup the corresponding structure */
586+
pmix_list_remove_item(&pmix_server_globals.local_reqs, (pmix_list_item_t*)ptr);
587+
PMIX_RELEASE(ptr);
588+
585589
return PMIX_SUCCESS;
586590
}
587591

opal/mca/pmix/pmix2x/pmix/src/server/pmix_server_ops.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1634,7 +1634,7 @@ static void lmcon(pmix_dmdx_local_t *p)
16341634
static void lmdes(pmix_dmdx_local_t *p)
16351635
{
16361636
PMIX_INFO_FREE(p->info, p->ninfo);
1637-
PMIX_DESTRUCT(&p->loc_reqs);
1637+
PMIX_LIST_DESTRUCT(&p->loc_reqs);
16381638
}
16391639
PMIX_CLASS_INSTANCE(pmix_dmdx_local_t,
16401640
pmix_list_item_t,

0 commit comments

Comments
 (0)