pmix_status_t pmix_add_errhandler(pmix_notification_fn_t err, pmix_info_t *info, int ninfo, int *index) { int i; pmix_status_t rc = PMIX_SUCCESS; pmix_error_reg_info_t *errreg; errreg = PMIX_NEW(pmix_error_reg_info_t); errreg->errhandler = err; errreg->ninfo = ninfo; if (NULL != info && 0 < ninfo) { PMIX_INFO_CREATE(errreg->info, ninfo); for (i=0; i < ninfo; i++) { (void)strncpy(errreg->info[i].key, info[i].key, PMIX_MAX_KEYLEN); pmix_value_xfer(&errreg->info[i].value, &info[i].value); } } *index = pmix_pointer_array_add(&pmix_globals.errregs, errreg); pmix_output_verbose(2, pmix_globals.debug_output, "pmix_add_errhandler index =%d", *index); if (*index < 0) { PMIX_RELEASE(errreg); rc = PMIX_ERROR; } return rc; }
pmix_status_t pmix_add_errhandler(pmix_notification_fn_t err, pmix_info_t *info, int ninfo, int *index) { int i; pmix_error_reg_info_t *errreg; if (0 != *index) { /* overwrite an existing entry */ errreg = (pmix_error_reg_info_t*)pmix_pointer_array_get_item(&pmix_globals.errregs, *index); if (NULL == errreg) { return PMIX_ERR_NOT_FOUND; } errreg->errhandler = err; PMIX_INFO_FREE(errreg->info, errreg->ninfo); errreg->ninfo = ninfo; } else { errreg = PMIX_NEW(pmix_error_reg_info_t); errreg->errhandler = err; errreg->ninfo = ninfo; *index = pmix_pointer_array_add(&pmix_globals.errregs, errreg); pmix_output_verbose(2, pmix_globals.debug_output, "pmix_add_errhandler index =%d", *index); if (*index < 0) { PMIX_RELEASE(errreg); return PMIX_ERROR; } } /* sadly, we have to copy the info objects as we cannot * rely on them to remain in-memory */ if (NULL != info && 0 < ninfo) { PMIX_INFO_CREATE(errreg->info, ninfo); for (i=0; i < ninfo; i++) { /* if this is a specific, single errhandler, then * mark it accordingly */ if (0 == strncmp(info[i].key, PMIX_ERROR_NAME, PMIX_MAX_KEYLEN)) { errreg->sglhdlr = true; } (void)strncpy(errreg->info[i].key, info[i].key, PMIX_MAX_KEYLEN); pmix_value_xfer(&errreg->info[i].value, &info[i].value); } } return PMIX_SUCCESS; }
pmix_status_t pmix_add_errhandler(pmix_notification_fn_t err, pmix_info_t *info, int ninfo, int *index) { int i; pmix_status_t rc = PMIX_SUCCESS; pmix_error_reg_info_t *errreg = PMIX_NEW(pmix_error_reg_info_t); errreg->errhandler = err; errreg->ninfo = ninfo; PMIX_INFO_CREATE(errreg->info, ninfo); for (i=0; i < ninfo; i++) { memcpy(errreg->info[i].key, info[i].key, PMIX_MAX_KEYLEN); pmix_value_xfer(&errreg->info[i].value, &info[i].value); } *index = pmix_pointer_array_add (&pmix_globals.errregs, errreg); if (-1 == *index) rc = PMIX_ERROR; return rc; }
static int group_register (const char *project_name, const char *framework_name, const char *component_name, const char *description) { pmix_mca_base_var_group_t *group; int group_id, parent_id = -1; int ret; if (NULL == project_name && NULL == framework_name && NULL == component_name) { /* don't create a group with no name (maybe we should create a generic group?) */ return -1; } /* avoid groups of the form pmix_pmix, etc */ if (NULL != project_name && NULL != framework_name && (0 == strcmp (project_name, framework_name))) { project_name = NULL; } group_id = group_find (project_name, framework_name, component_name, true); if (0 <= group_id) { ret = pmix_mca_base_var_group_get_internal (group_id, &group, true); if (PMIX_SUCCESS != ret) { /* something went horribly wrong */ assert (NULL != group); return ret; } group->group_isvalid = true; pmix_mca_base_var_groups_timestamp++; /* group already exists. return it's index */ return group_id; } group = PMIX_NEW(pmix_mca_base_var_group_t); group->group_isvalid = true; if (NULL != project_name) { group->group_project = strdup (project_name); if (NULL == group->group_project) { PMIX_RELEASE(group); return PMIX_ERR_OUT_OF_RESOURCE; } } if (NULL != framework_name) { group->group_framework = strdup (framework_name); if (NULL == group->group_framework) { PMIX_RELEASE(group); return PMIX_ERR_OUT_OF_RESOURCE; } } if (NULL != component_name) { group->group_component = strdup (component_name); if (NULL == group->group_component) { PMIX_RELEASE(group); return PMIX_ERR_OUT_OF_RESOURCE; } } if (NULL != description) { group->group_description = strdup (description); if (NULL == group->group_description) { PMIX_RELEASE(group); return PMIX_ERR_OUT_OF_RESOURCE; } } if (NULL != framework_name && NULL != component_name) { parent_id = group_register (project_name, framework_name, NULL, NULL); } /* build the group name */ ret = pmix_mca_base_var_generate_full_name4 (NULL, project_name, framework_name, component_name, &group->group_full_name); if (PMIX_SUCCESS != ret) { PMIX_RELEASE(group); return ret; } group_id = pmix_pointer_array_add (&pmix_mca_base_var_groups, group); if (0 > group_id) { PMIX_RELEASE(group); return PMIX_ERROR; } pmix_hash_table_set_value_ptr (&pmix_mca_base_var_group_index_hash, group->group_full_name, strlen (group->group_full_name), (void *)(uintptr_t) group_id); pmix_mca_base_var_group_count++; pmix_mca_base_var_groups_timestamp++; if (0 <= parent_id) { pmix_mca_base_var_group_t *parent_group; (void) pmix_mca_base_var_group_get_internal(parent_id, &parent_group, false); pmix_value_array_append_item (&parent_group->group_subgroups, &group_id); } return group_id; }
static pmix_peer_t* find_peer(const pmix_proc_t *proc) { pmix_status_t rc; pmix_peer_t *peer; pmix_proc_t wildcard; pmix_value_t *value; int i; if (NULL == proc ) { return pmix_globals.mypeer; } /* if the target is someone in my nspace, then use my own peer */ if (0 == strncmp(proc->nspace, pmix_globals.myid.nspace, PMIX_MAX_NSLEN)) { return pmix_globals.mypeer; } if (PMIX_PROC_IS_SERVER(pmix_globals.mypeer)) { /* see if we know this proc */ for (i=0; i < pmix_server_globals.clients.size; i++) { if (NULL != (peer = (pmix_peer_t*)pmix_pointer_array_get_item(&pmix_server_globals.clients, i))) { continue; } if (0 == strncmp(proc->nspace, peer->nptr->nspace, PMIX_MAX_NSLEN)) { return peer; } } /* didn't find it, so try to get the library version of the target * from the host - the result will be cached, so we will only have * to retrieve it once */ (void)strncpy(wildcard.nspace, proc->nspace, PMIX_MAX_NSLEN); wildcard.rank = PMIX_RANK_WILDCARD; if (PMIX_SUCCESS != (rc = PMIx_Get(&wildcard, PMIX_BFROPS_MODULE, NULL, 0, &value))) { /* couldn't get it - nothing we can do */ return NULL; } /* setup a peer for this nspace */ peer = PMIX_NEW(pmix_peer_t); if (NULL == peer) { PMIX_RELEASE(value); return NULL; } peer->nptr = PMIX_NEW(pmix_nspace_t); if (NULL == peer->nptr) { PMIX_RELEASE(peer); PMIX_RELEASE(value); return NULL; } peer->nptr->nspace = strdup(proc->nspace); /* assign a module to it based on the returned version */ peer->nptr->compat.bfrops = pmix_bfrops_base_assign_module(value->data.string); PMIX_RELEASE(value); if (NULL == peer->nptr->compat.bfrops) { PMIX_RELEASE(peer); return NULL; } /* cache the peer object */ pmix_pointer_array_add(&pmix_server_globals.clients, peer); return peer; } // we are a client or tool /* If the target is for the server, then * pack it using that peer. */ if (0 == strncmp(proc->nspace, pmix_client_globals.myserver->info->pname.nspace, PMIX_MAX_NSLEN)) { return pmix_client_globals.myserver; } /* if the target is another member of my nspace, then * they must be using the same version */ if (0 == strncmp(proc->nspace, pmix_globals.myid.nspace, PMIX_MAX_NSLEN)) { return pmix_globals.mypeer; } /* try to get the library version of this peer - the result will be * cached, so we will only have to retrieve it once */ (void)strncpy(wildcard.nspace, proc->nspace, PMIX_MAX_NSLEN); wildcard.rank = PMIX_RANK_WILDCARD; if (PMIX_SUCCESS != (rc = PMIx_Get(&wildcard, PMIX_BFROPS_MODULE, NULL, 0, &value))) { /* couldn't get it - nothing we can do */ return NULL; } /* setup a peer for this nspace */ peer = PMIX_NEW(pmix_peer_t); if (NULL == peer) { PMIX_RELEASE(value); return NULL; } peer->nptr = PMIX_NEW(pmix_nspace_t); if (NULL == peer->nptr) { PMIX_RELEASE(peer); PMIX_RELEASE(value); return NULL; } peer->nptr->nspace = strdup(proc->nspace); /* assign a module to it based on the returned version */ peer->nptr->compat.bfrops = pmix_bfrops_base_assign_module(value->data.string); PMIX_RELEASE(value); if (NULL == peer->nptr->compat.bfrops) { PMIX_RELEASE(peer); return NULL; } /* need to cache the peer someplace so we can clean it * up later */ return peer; }