@@ -230,6 +230,45 @@ static void return_local_event_hdlr(int status, opal_list_t *results,
230230 }
231231}
232232
233+ /* process the notification */
234+ static void process_event (int sd , short args , void * cbdata )
235+ {
236+ pmix2x_threadshift_t * cd = (pmix2x_threadshift_t * )cbdata ;
237+ opal_pmix2x_event_t * event ;
238+
239+ OPAL_PMIX_ACQUIRE_THREAD (& opal_pmix_base .lock );
240+
241+ /* cycle thru the registrations */
242+ OPAL_LIST_FOREACH (event , & mca_pmix_pmix2x_component .events , opal_pmix2x_event_t ) {
243+ if (cd -> id == event -> index ) {
244+ /* found it - invoke the handler, pointing its
245+ * callback function to our callback function */
246+ opal_output_verbose (2 , opal_pmix_base_framework .framework_output ,
247+ "%s _EVENT_HDLR CALLING EVHDLR" ,
248+ OPAL_NAME_PRINT (OPAL_PROC_MY_NAME ));
249+ if (NULL != event -> handler ) {
250+ OBJ_RETAIN (event );
251+ OPAL_PMIX_RELEASE_THREAD (& opal_pmix_base .lock );
252+ event -> handler (cd -> status , & cd -> pname ,
253+ cd -> info , & cd -> results ,
254+ return_local_event_hdlr , cd );
255+ OBJ_RELEASE (event );
256+ return ;
257+ }
258+ }
259+ }
260+
261+ OPAL_PMIX_RELEASE_THREAD (& opal_pmix_base .lock );
262+
263+ /* if we didn't find a match, we still have to call their final callback */
264+ if (NULL != cd -> pmixcbfunc ) {
265+ cd -> pmixcbfunc (PMIX_SUCCESS , NULL , 0 , NULL , NULL , cd -> cbdata );
266+ }
267+ OPAL_LIST_RELEASE (cd -> info );
268+ OBJ_RELEASE (cd );
269+ return ;
270+ }
271+
233272/* this function will be called by the PMIx client library
234273 * whenever it receives notification of an event. The
235274 * notification can come from an ORTE daemon (when launched
@@ -247,7 +286,6 @@ void pmix2x_event_hdlr(size_t evhdlr_registration_id,
247286 int rc ;
248287 opal_value_t * iptr ;
249288 size_t n ;
250- opal_pmix2x_event_t * event ;
251289
252290 opal_output_verbose (2 , opal_pmix_base_framework .framework_output ,
253291 "%s RECEIVED NOTIFICATION OF STATUS %d" ,
@@ -307,34 +345,12 @@ void pmix2x_event_hdlr(size_t evhdlr_registration_id,
307345 }
308346 }
309347
310- /* cycle thru the registrations */
311- OPAL_LIST_FOREACH (event , & mca_pmix_pmix2x_component .events , opal_pmix2x_event_t ) {
312- if (evhdlr_registration_id == event -> index ) {
313- /* found it - invoke the handler, pointing its
314- * callback function to our callback function */
315- opal_output_verbose (2 , opal_pmix_base_framework .framework_output ,
316- "%s _EVENT_HDLR CALLING EVHDLR" ,
317- OPAL_NAME_PRINT (OPAL_PROC_MY_NAME ));
318- if (NULL != event -> handler ) {
319- OBJ_RETAIN (event );
320- OPAL_PMIX_RELEASE_THREAD (& opal_pmix_base .lock );
321- event -> handler (cd -> status , & cd -> pname ,
322- cd -> info , & cd -> results ,
323- return_local_event_hdlr , cd );
324- OBJ_RELEASE (event );
325- return ;
326- }
327- }
328- }
329-
330348 OPAL_PMIX_RELEASE_THREAD (& opal_pmix_base .lock );
331349
332- /* if we didn't find a match, we still have to call their final callback */
333- if (NULL != cbfunc ) {
334- cbfunc (PMIX_SUCCESS , NULL , 0 , NULL , NULL , cbdata );
335- }
336- OPAL_LIST_RELEASE (cd -> info );
337- OBJ_RELEASE (cd );
350+ /* do NOT directly call the event handler as this
351+ * may lead to a deadlock condition should the
352+ * handler invoke a PMIx function */
353+ OPAL_PMIX2X_THREADSHIFT (cd , process_event );
338354 return ;
339355}
340356
0 commit comments