3232#include "opal/mca/hwloc/base/base.h"
3333#include "opal/runtime/opal.h"
3434#include "opal/runtime/opal_progress_threads.h"
35+ #include "opal/threads/threads.h"
3536#include "opal/util/argv.h"
3637#include "opal/util/error.h"
3738#include "opal/util/output.h"
@@ -58,6 +59,7 @@ static size_t errhdler_ref = 0;
5859 while ((a)) { \
5960 usleep(10); \
6061 } \
62+ OPAL_ACQUIRE_OBJECT(a); \
6163 } while (0)
6264
6365static void errreg_cbfunc (pmix_status_t status ,
@@ -66,22 +68,27 @@ static void errreg_cbfunc (pmix_status_t status,
6668{
6769 volatile bool * active = (volatile bool * )cbdata ;
6870
71+ OPAL_ACQUIRE_OBJECT (active );
6972 errhdler_ref = errhandler_ref ;
7073 opal_output_verbose (5 , opal_pmix_base_framework .framework_output ,
7174 "PMIX server errreg_cbfunc - error handler registered status=%d, reference=%lu" ,
7275 status , (unsigned long )errhandler_ref );
76+ OPAL_POST_OBJECT (active );
7377 * active = false;
7478}
7579
7680static void opcbfunc (pmix_status_t status , void * cbdata )
7781{
7882 pmix2x_opcaddy_t * op = (pmix2x_opcaddy_t * )cbdata ;
7983
84+ OPAL_ACQUIRE_OBJECT (op );
85+
8086 if (NULL != op -> opcbfunc ) {
8187 op -> opcbfunc (pmix2x_convert_rc (status ), op -> cbdata );
8288 }
8389 if (op -> active ) {
8490 op -> status = status ;
91+ OPAL_POST_OBJECT (op );
8592 op -> active = false;
8693 } else {
8794 OBJ_RELEASE (op );
@@ -92,6 +99,7 @@ static void op2cbfunc(pmix_status_t status, void *cbdata)
9299{
93100 volatile bool * active = (volatile bool * )cbdata ;
94101
102+ OPAL_POST_OBJECT (active );
95103 * active = false;
96104}
97105
@@ -165,6 +173,7 @@ int pmix2x_server_init(opal_pmix_server_module_t *module,
165173static void fincb (pmix_status_t status , void * cbdata )
166174{
167175 volatile bool * active = (volatile bool * )cbdata ;
176+ OPAL_POST_OBJECT (active );
168177 * active = false;
169178}
170179
@@ -211,6 +220,8 @@ static void _reg_nspace(int sd, short args, void *cbdata)
211220 opal_pmix2x_jobid_trkr_t * job ;
212221 pmix2x_opcaddy_t op ;
213222
223+ OPAL_ACQUIRE_OBJECT (cd );
224+
214225 /* we must threadshift this request as we might not be in an event
215226 * and we are going to access framework-global lists/objects */
216227
@@ -301,6 +312,7 @@ int pmix2x_server_register_nspace(opal_jobid_t jobid,
301312 } else {
302313 opal_event_assign (& cd -> ev , opal_pmix_base .evbase ,
303314 -1 , EV_WRITE , _reg_nspace , cd );
315+ OPAL_POST_OBJECT (cd );
304316 opal_event_active (& cd -> ev , EV_WRITE , 1 );
305317 }
306318
@@ -311,10 +323,12 @@ static void tdcbfunc(pmix_status_t status, void *cbdata)
311323{
312324 pmix2x_threadshift_t * cd = (pmix2x_threadshift_t * )cbdata ;
313325
326+ OPAL_ACQUIRE_OBJECT (cd );
314327 if (NULL != cd -> opcbfunc ) {
315328 cd -> opcbfunc (pmix2x_convert_rc (status ), cd -> cbdata );
316329 }
317330 if (cd -> active ) {
331+ OPAL_POST_OBJECT (cd );
318332 cd -> active = false;
319333 } else {
320334 OBJ_RELEASE (cd );
@@ -326,6 +340,7 @@ static void _dereg_nspace(int sd, short args, void *cbdata)
326340 pmix2x_threadshift_t * cd = (pmix2x_threadshift_t * )cbdata ;
327341 opal_pmix2x_jobid_trkr_t * jptr ;
328342
343+ OPAL_ACQUIRE_OBJECT (cd );
329344 /* if we don't already have it, we can ignore this */
330345 OPAL_LIST_FOREACH (jptr , & mca_pmix_pmix2x_component .jobids , opal_pmix2x_jobid_trkr_t ) {
331346 if (jptr -> jobid == cd -> jobid ) {
@@ -361,6 +376,7 @@ void pmix2x_server_deregister_nspace(opal_jobid_t jobid,
361376 } else {
362377 opal_event_assign (& cd -> ev , opal_pmix_base .evbase ,
363378 -1 , EV_WRITE , _dereg_nspace , cd );
379+ OPAL_POST_OBJECT (cd );
364380 opal_event_active (& cd -> ev , EV_WRITE , 1 );
365381 }
366382}
@@ -397,6 +413,7 @@ static void _dereg_client(int sd, short args, void *cbdata)
397413 opal_pmix2x_jobid_trkr_t * jptr ;
398414 pmix_proc_t p ;
399415
416+ OPAL_ACQUIRE_OBJECT (cd );
400417 /* if we don't already have it, we can ignore this */
401418 OPAL_LIST_FOREACH (jptr , & mca_pmix_pmix2x_component .jobids , opal_pmix2x_jobid_trkr_t ) {
402419 if (jptr -> jobid == cd -> source -> jobid ) {
@@ -431,6 +448,7 @@ void pmix2x_server_deregister_client(const opal_process_name_t *proc,
431448 } else {
432449 opal_event_assign (& cd -> ev , opal_pmix_base .evbase ,
433450 -1 , EV_WRITE , _dereg_client , cd );
451+ OPAL_POST_OBJECT (cd );
434452 opal_event_active (& cd -> ev , EV_WRITE , 1 );
435453 }
436454}
0 commit comments