static void _dmdx_resp(Buf buf, char *sender_host, uint32_t seq_num) { dmdx_req_info_t *req; int rank, rc = SLURM_SUCCESS; int status; char *ns = NULL, *sender_ns = NULL; char *data = NULL; uint32_t size = 0; /* find the request tracker */ ListIterator it = list_iterator_create(_dmdx_requests); req = (dmdx_req_info_t *)list_find(it, _dmdx_req_cmp, &seq_num); if (NULL == req) { /* We haven't sent this request! */ PMIXP_ERROR("Received DMDX response with bad " "seq_num=%d from %s!", seq_num, sender_host); list_iterator_destroy(it); rc = SLURM_ERROR; goto exit; } /* get the service data */ rc = _read_info(buf, &ns, &rank, &sender_ns, &status); if (SLURM_SUCCESS != rc) { /* notify libpmix about an error */ req->cbfunc(PMIX_ERROR, NULL, 0, req->cbdata, NULL, NULL); goto exit; } /* get the modex blob */ if (SLURM_SUCCESS != (rc = unpackmem_ptr(&data, &size, buf))) { /* notify libpmix about an error */ req->cbfunc(PMIX_ERROR, NULL, 0, req->cbdata, NULL, NULL); goto exit; } /* call back to libpmix-server */ req->cbfunc(status, data, size, req->cbdata, pmixp_free_Buf, (void *)buf); /* release tracker & list iterator */ req = NULL; list_delete_item(it); list_iterator_destroy(it); exit: if (SLURM_SUCCESS != rc) { /* we are not expect libpmix to call the callback * to cleanup this buffer */ free_buf(buf); } /* no sense to return errors, engine can't do anything * anyway. We've notified libpmix, that's enough */ }
static int _read_info(Buf buf, char **ns, int *rank, char **sender_ns, int *status) { uint32_t cnt, uint32_tmp; int rc; *ns = NULL; *sender_ns = NULL; /* 1. unpack namespace */ if (SLURM_SUCCESS != (rc = unpackmem_ptr(ns, &cnt, buf))) { PMIXP_ERROR("Cannot unpack requested namespace!"); return rc; } /* We supposed to unpack a whole null-terminated string (with '\0')! * (*ns)[cnt] = '\0'; */ /* 2. unpack rank */ if (SLURM_SUCCESS != (rc = unpack32(&uint32_tmp, buf))) { PMIXP_ERROR("Cannot unpack requested rank!"); return rc; } *rank = uint32_tmp; if (SLURM_SUCCESS != (rc = unpackmem_ptr(sender_ns, &cnt, buf))) { PMIXP_ERROR("Cannot unpack sender namespace!"); return rc; } /* We supposed to unpack a whole null-terminated string (with '\0')! * (*sender_ns)[cnt] = '\0'; */ /* 4. unpack status */ if (SLURM_SUCCESS != (rc = unpack32(&uint32_tmp, buf))) { PMIXP_ERROR("Cannot unpack rank!"); return rc; } *status = uint32_tmp; return SLURM_SUCCESS; }
/* * long double has no standard format, so pass the data as a string */ int unpacklongdouble(long double *valp, Buf buffer) { long double nl; char *val_str = NULL; uint32_t size_val_str = 0; int rc; rc = unpackmem_ptr(&val_str, &size_val_str, buffer); if (rc != SLURM_SUCCESS) return rc; if (sscanf(val_str, "%Lf", &nl) != 1) return SLURM_ERROR; *valp = nl; return SLURM_SUCCESS; }