Skip to content

Commit

Permalink
Remove the "refresh" key before requesting dmodx from PMIx server
Browse files Browse the repository at this point in the history
Ensure that any "refresh" key does not get passed down to the
PMIx dmodex request interface as this leads to a circular
behavior. Remove an unused static function.

Signed-off-by: Ralph Castain <rhc@pmix.org>
  • Loading branch information
rhc54 committed Dec 1, 2023
1 parent 5b7e09b commit 7fe2b33
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 61 deletions.
49 changes: 43 additions & 6 deletions src/prted/pmix/pmix_server.c
Original file line number Diff line number Diff line change
Expand Up @@ -1206,10 +1206,11 @@ static void pmix_server_dmdx_recv(int status, pmix_proc_t *sender,
pmix_server_req_t *req;
pmix_proc_t pproc;
pmix_status_t prc;
pmix_info_t *info = NULL;
pmix_info_t *info = NULL, *iptr;
size_t ninfo;
char *key = NULL;
size_t sz;
size_t sz, n, refreshidx;
bool refresh_cache = false;
pmix_value_t *pval = NULL;
PRTE_HIDE_UNUSED_PARAMS(status, tg, cbdata);

Expand Down Expand Up @@ -1247,7 +1248,7 @@ static void pmix_server_dmdx_recv(int status, pmix_proc_t *sender,
if (NULL != info) {
for (sz = 0; sz < ninfo; sz++) {
if (PMIX_CHECK_KEY(&info[sz], PMIX_REQUIRED_KEY)) {
key = info[sz].value.data.string;
key = strdup(info[sz].value.data.string);
continue;
}
if (PMIX_CHECK_KEY(&info[sz], PMIX_TIMEOUT)) {
Expand All @@ -1261,6 +1262,34 @@ static void pmix_server_dmdx_recv(int status, pmix_proc_t *sender,
}
continue;
}
if (PMIX_CHECK_KEY(&info[sz], PMIX_GET_REFRESH_CACHE)) {
refresh_cache = PMIX_INFO_TRUE(&info[sz]);
refreshidx = sz;
continue;
}
}
}

if (refresh_cache) {
if (1 < ninfo) {
// need to remove the refresh cache key to avoid loops
PMIX_INFO_CREATE(iptr, ninfo - 1);
sz = 0;
for (n = 0; n < ninfo; n++) {
if (n == refreshidx) {
continue;
}
PMIX_INFO_XFER(&iptr[sz], &info[n]);
++sz;
}
PMIX_INFO_FREE(info, ninfo);
info = iptr;
ninfo = sz;
} else {
// refresh was the only key
PMIX_INFO_FREE(info, ninfo);
info = NULL;
ninfo = 0;
}
}

Expand All @@ -1281,7 +1310,8 @@ static void pmix_server_dmdx_recv(int status, pmix_proc_t *sender,
req->info = info;
req->ninfo = ninfo;
if (NULL != key) {
req->key = strdup(key);
req->key = key;
key = NULL;
}
/* store THEIR index to the request */
req->remote_index = index;
Expand Down Expand Up @@ -1321,7 +1351,8 @@ static void pmix_server_dmdx_recv(int status, pmix_proc_t *sender,
}

if (NULL != key) {
pmix_output_verbose(2, prte_pmix_server_globals.output, "%s dmdx:recv checking for key %s",
pmix_output_verbose(2, prte_pmix_server_globals.output,
"%s dmdx:recv checking for key %s",
PRTE_NAME_PRINT(PRTE_PROC_MY_NAME), key);
/* see if we have it */
if (PMIX_SUCCESS != PMIx_Get(&pproc, key, info, ninfo, &pval)) {
Expand All @@ -1335,7 +1366,8 @@ static void pmix_server_dmdx_recv(int status, pmix_proc_t *sender,
memcpy(&req->tproc, &pproc, sizeof(pmix_proc_t));
req->info = info;
req->ninfo = ninfo;
req->key = strdup(key);
req->key = key;
key = NULL;
req->remote_index = index;
/* store it in my remote reqs, assigning the index in that array
* to the req->local_index as this is MY index to the request */
Expand Down Expand Up @@ -1365,6 +1397,11 @@ static void pmix_server_dmdx_recv(int status, pmix_proc_t *sender,
PRTE_NAME_PRINT(PRTE_PROC_MY_NAME), key);
}

if (NULL != key) {
free(key);
key = NULL;
}

/* track the request since the call down to the PMIx server
* is asynchronous */
req = PMIX_NEW(pmix_server_req_t);
Expand Down
55 changes: 0 additions & 55 deletions src/prted/pmix/pmix_server_fence.c
Original file line number Diff line number Diff line change
Expand Up @@ -140,61 +140,6 @@ pmix_status_t pmix_server_fencenb_fn(const pmix_proc_t procs[], size_t nprocs,
return PMIX_SUCCESS;
}

static void modex_resp(pmix_status_t status, char *data, size_t sz, void *cbdata)
{
pmix_server_req_t *req = (pmix_server_req_t *) cbdata;
pmix_data_buffer_t *reply;
pmix_status_t prc;

PMIX_ACQUIRE_OBJECT(req);

/* pack the status */
PMIX_DATA_BUFFER_CREATE(reply);
if (PMIX_SUCCESS != (prc = PMIx_Data_pack(NULL, reply, &status, 1, PMIX_STATUS))) {
PMIX_ERROR_LOG(prc);
PMIX_DATA_BUFFER_RELEASE(reply);
goto error;
}
/* pack the id of the requested proc */
if (PMIX_SUCCESS != (prc = PMIx_Data_pack(NULL, reply, &req->tproc, 1, PMIX_PROC))) {
PMIX_ERROR_LOG(prc);
PMIX_DATA_BUFFER_RELEASE(reply);
goto error;
}

/* pack the remote daemon's request room number */
if (PMIX_SUCCESS != (prc = PMIx_Data_pack(NULL, reply, &req->remote_index, 1, PMIX_INT))) {
PMIX_ERROR_LOG(prc);
PMIX_DATA_BUFFER_RELEASE(reply);
goto error;
}
if (PMIX_SUCCESS == status) {
/* return any provided data */
if (PMIX_SUCCESS != (prc = PMIx_Data_pack(NULL, reply, &sz, 1, PMIX_SIZE))) {
PMIX_ERROR_LOG(prc);
PMIX_DATA_BUFFER_RELEASE(reply);
goto error;
}
if (0 < sz) {
if (PMIX_SUCCESS != (prc = PMIx_Data_pack(NULL, reply, data, sz, PMIX_BYTE))) {
PMIX_ERROR_LOG(prc);
PMIX_DATA_BUFFER_RELEASE(reply);
goto error;
}
}
}

/* send the response */
PRTE_RML_SEND(prc, req->proxy.rank, reply, PRTE_RML_TAG_DIRECT_MODEX_RESP);
if (PRTE_SUCCESS != prc) {
PRTE_ERROR_LOG(prc);
PMIX_DATA_BUFFER_RELEASE(reply);
}

error:
PMIX_RELEASE(req);
return;
}

static void dmodex_req(int sd, short args, void *cbdata)
{
Expand Down

0 comments on commit 7fe2b33

Please sign in to comment.