@@ -30,7 +30,7 @@ static bool requests_initialized = false;
30
30
static opal_list_t requests ;
31
31
static opal_atomic_int32_t active_requests = 0 ;
32
32
static bool in_progress = false;
33
- static opal_mutex_t lock ;
33
+ static opal_mutex_t lock = OPAL_MUTEX_STATIC_INIT ;
34
34
35
35
static int grequestx_progress (void ) {
36
36
ompi_grequest_t * request , * next ;
@@ -47,6 +47,7 @@ static int grequestx_progress(void) {
47
47
OPAL_THREAD_LOCK (& lock );
48
48
if (REQUEST_COMPLETE (& request -> greq_base )) {
49
49
opal_list_remove_item (& requests , & request -> greq_base .super .super );
50
+ OBJ_RELEASE (request );
50
51
completed ++ ;
51
52
}
52
53
}
@@ -73,13 +74,17 @@ int ompi_grequestx_start(
73
74
}
74
75
((ompi_grequest_t * )* request )-> greq_poll .c_poll = gpoll_fn ;
75
76
77
+ /* prevent the request from being destroyed upon completion,
78
+ * we first have to remove it from the list of active requests
79
+ */
80
+ OBJ_RETAIN (((ompi_grequest_t * )* request ));
81
+
82
+ OPAL_THREAD_LOCK (& lock );
76
83
if (!requests_initialized ) {
77
84
OBJ_CONSTRUCT (& requests , opal_list_t );
78
- OBJ_CONSTRUCT (& lock , opal_mutex_t );
79
85
requests_initialized = true;
80
86
}
81
87
82
- OPAL_THREAD_LOCK (& lock );
83
88
opal_list_append (& requests , & ((* request )-> super .super ));
84
89
OPAL_THREAD_UNLOCK (& lock );
85
90
int32_t tmp = OPAL_THREAD_ADD_FETCH32 (& active_requests , 1 );
0 commit comments