Skip to content

Commit a5b95a0

Browse files
Ralph Castainggouaillardet
authored andcommitted
Continue work on error notification system
1 parent 810f244 commit a5b95a0

File tree

2 files changed

+55
-50
lines changed

2 files changed

+55
-50
lines changed

opal/mca/pmix/pmix120/pmix/src/server/pmix_server.c

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -626,9 +626,7 @@ pmix_status_t PMIx_server_register_nspace(const char nspace[], int nlocalprocs,
626626

627627
/* we have to push this into our event library to avoid
628628
* potential threading issues */
629-
event_assign(&cd->ev, pmix_globals.evbase, -1,
630-
EV_WRITE, _register_nspace, cd);
631-
event_active(&cd->ev, EV_WRITE, 1);
629+
PMIX_THREADSHIFT(cd, _register_nspace);
632630
return PMIX_SUCCESS;
633631
}
634632

@@ -666,9 +664,7 @@ void PMIx_server_deregister_nspace(const char nspace[])
666664

667665
/* we have to push this into our event library to avoid
668666
* potential threading issues */
669-
event_assign(&cd->ev, pmix_globals.evbase, -1,
670-
EV_WRITE, _deregister_nspace, cd);
671-
event_active(&cd->ev, EV_WRITE, 1);
667+
PMIX_THREADSHIFT(cd, _deregister_nspace);
672668
}
673669

674670
static void _execute_collective(int sd, short args, void *cbdata)
@@ -847,9 +843,7 @@ pmix_status_t PMIx_server_register_client(const pmix_proc_t *proc,
847843

848844
/* we have to push this into our event library to avoid
849845
* potential threading issues */
850-
event_assign(&cd->ev, pmix_globals.evbase, -1,
851-
EV_WRITE, _register_client, cd);
852-
event_active(&cd->ev, EV_WRITE, 1);
846+
PMIX_THREADSHIFT(cd, _register_client);
853847
return PMIX_SUCCESS;
854848
}
855849

@@ -902,9 +896,7 @@ void PMIx_server_deregister_client(const pmix_proc_t *proc)
902896

903897
/* we have to push this into our event library to avoid
904898
* potential threading issues */
905-
event_assign(&cd->ev, pmix_globals.evbase, -1,
906-
EV_WRITE, _deregister_client, cd);
907-
event_active(&cd->ev, EV_WRITE, 1);
899+
PMIX_THREADSHIFT(cd, _deregister_client);
908900
}
909901

910902
/* setup the envars for a child process */
@@ -1049,9 +1041,8 @@ pmix_status_t PMIx_server_dmodex_request(const pmix_proc_t *proc,
10491041

10501042
/* we have to push this into our event library to avoid
10511043
* potential threading issues */
1052-
event_assign(&cd->ev, pmix_globals.evbase, -1,
1053-
EV_WRITE, _dmodex_req, cd);
1054-
event_active(&cd->ev, EV_WRITE, 1);
1044+
PMIX_THREADSHIFT(cd, _dmodex_req);
1045+
10551046
PMIX_WAIT_FOR_COMPLETION(cd->active);
10561047
PMIX_RELEASE(cd);
10571048
return PMIX_SUCCESS;
@@ -1227,9 +1218,7 @@ pmix_status_t pmix_server_notify_error(pmix_status_t status,
12271218

12281219
/* we have to push this into our event library to avoid
12291220
* potential threading issues */
1230-
event_assign(&cd->ev, pmix_globals.evbase, -1,
1231-
EV_WRITE, _notify_error, cd);
1232-
event_active(&cd->ev, EV_WRITE, 1);
1221+
PMIX_THREADSHIFT(cd, _notify_error);
12331222
return PMIX_SUCCESS;
12341223
}
12351224

opal/mca/pmix/pmix120/pmix/src/util/error.c

Lines changed: 48 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -152,51 +152,67 @@ void pmix_errhandler_invoke(pmix_status_t status,
152152
pmix_proc_t procs[], size_t nprocs,
153153
pmix_info_t info[], size_t ninfo)
154154
{
155-
#if 0
156155
/* We need to parse thru each registered handler and determine
157156
* which one to call for the specific error */
158-
int i;
157+
int i, idflt;
159158
size_t j, k;
160-
bool exact_match = false;
159+
bool fired = false;
160+
bool exact_match;
161161
int allerrhandler_ind = -1;
162-
pmix_error_reg_info_t *errreg;
162+
pmix_error_reg_info_t *errreg, *errdflt=NULL;
163+
pmix_info_t *iptr;
164+
165+
PMIX_INFO_CREATE(iptr, ninfo+1);
166+
(void)strncpy(iptr[0].key, PMIX_ERROR_HANDLER_ID, PMIX_MAX_KEYLEN);
167+
iptr[0].value.type = PMIX_INT;
168+
for (j=0; j < ninfo; j++) {
169+
PMIX_INFO_LOAD(&iptr[j+1], info[j].key, &info[j].value.data, info[j].value.type);
170+
}
163171

164-
for (i = 0; i < pmix_globals.errregs.size && !exact_match; i++) {
172+
for (i = 0; i < pmix_globals.errregs.size; i++) {
165173
if (NULL == (errreg = (pmix_error_reg_info_t*) pmix_pointer_array_get_item(&pmix_globals.errregs, i))) {
166174
continue;
167175
}
168-
if (0 == errreg->ninfo) {
169-
// this is a general err handler we will call it if there is no better match
170-
allerrhandler_ind = i;
171-
} else {
172-
/* match error name key first */
173-
for (j = 0; j < errreg->ninfo; j++) {
174-
if ((0 == strcmp(errreg->info[j].key, PMIX_ERROR_NAME)) &&
175-
(status == errreg->info[j].value.data.int32)) {
176-
exact_match = true;
177-
break;
178-
} else {
179-
for (k = 0; k < errreg->ninfo; k++) {
180-
if ((0 == strcmp(errreg->info[j].key, info[k].key)) &&
181-
(pmix_value_cmp(&errreg->info[j].value, &info[k].value))) {
182-
break;
183-
}
184-
}
176+
if (NULL == errreg->info || 0 == errreg->ninfo) {
177+
// this is a general err handler - we will call it if there is no better match
178+
errdflt = errreg;
179+
idflt = i;
180+
continue;
181+
}
182+
iptr[0].value.data.integer = i;
183+
/* match error name key first */
184+
exact_match = false;
185+
for (j = 0; j < errreg->ninfo; j++) {
186+
if ((0 == strcmp(errreg->info[j].key, PMIX_ERROR_NAME)) &&
187+
(status == errreg->info[j].value.data.int32)) {
188+
iptr[0].value.data.integer = i;
189+
errreg->errhandler(status, procs, nprocs, iptr, ninfo+1);
190+
fired = true;
191+
exact_match = true;
192+
break;
193+
}
194+
}
195+
if (!exact_match) {
196+
/* if no exact match was found, then we will fire the errhandler
197+
* for any matching info key. This may be too lax and need to be adjusted
198+
* later */
199+
for (k = 0; k < errreg->ninfo; k++) {
200+
if ((0 == strcmp(errreg->info[j].key, info[k].key)) &&
201+
(pmix_value_cmp(&errreg->info[j].value, &info[k].value))) {
202+
errreg->errhandler(status, procs, nprocs, iptr, ninfo+1);
203+
fired = true;
185204
}
186205
}
187206
}
188207
}
189-
for ( i =0 ;i < nmatched; i++) {
190-
errreg = (pmix_error_reg_info_t*) pmix_pointer_array_get_item (&pmix_globals.errregs,
191-
matched_errregs[i]);
192-
errreg->errhandler(status, procs, nprocs, info, ninfo);
193-
}
194-
if ( 0 == nmatched && 0 <= allerrhandler_ind) {
195-
errreg = (pmix_error_reg_info_t*) pmix_pointer_array_get_item (&pmix_globals.errregs,
196-
allerrhandler_ind);
197-
errreg->errhandler(status, procs, nprocs, info, ninfo);
208+
209+
/* if nothing fired and we found a general err handler, then fire it */
210+
if (!fired && NULL != errdflt) {
211+
iptr[0].value.data.integer = idflt;
212+
errdflt->errhandler(status, procs, nprocs, iptr, ninfo+1);
198213
}
199-
#endif
214+
/* cleanup */
215+
PMIX_INFO_FREE(iptr, ninfo+1);
200216
}
201217

202218
pmix_status_t pmix_lookup_errhandler(pmix_notification_fn_t err,

0 commit comments

Comments
 (0)