@@ -50,7 +50,8 @@ mca_btl_tcp_module_t mca_btl_tcp_module = {
50
50
.btl_put = mca_btl_tcp_put ,
51
51
.btl_dump = mca_btl_base_dump ,
52
52
.btl_ft_event = mca_btl_tcp_ft_event
53
- }
53
+ },
54
+ .tcp_endpoints_mutex = OPAL_MUTEX_STATIC_INIT
54
55
};
55
56
56
57
/**
@@ -122,7 +123,9 @@ int mca_btl_tcp_add_procs( struct mca_btl_base_module_t* btl,
122
123
continue ;
123
124
}
124
125
126
+ OPAL_THREAD_LOCK (& tcp_btl -> tcp_endpoints_mutex );
125
127
opal_list_append (& tcp_btl -> tcp_endpoints , (opal_list_item_t * )tcp_endpoint );
128
+ OPAL_THREAD_UNLOCK (& tcp_btl -> tcp_endpoints_mutex );
126
129
}
127
130
128
131
OPAL_THREAD_UNLOCK (& tcp_proc -> proc_lock );
@@ -143,12 +146,14 @@ int mca_btl_tcp_add_procs( struct mca_btl_base_module_t* btl,
143
146
}
144
147
145
148
int mca_btl_tcp_del_procs (struct mca_btl_base_module_t * btl ,
146
- size_t nprocs ,
147
- struct opal_proc_t * * procs ,
148
- struct mca_btl_base_endpoint_t * * endpoints )
149
+ size_t nprocs ,
150
+ struct opal_proc_t * * procs ,
151
+ struct mca_btl_base_endpoint_t * * endpoints )
149
152
{
150
153
mca_btl_tcp_module_t * tcp_btl = (mca_btl_tcp_module_t * )btl ;
151
154
size_t i ;
155
+
156
+ OPAL_THREAD_LOCK (& tcp_btl -> tcp_endpoints_mutex );
152
157
for ( i = 0 ; i < nprocs ; i ++ ) {
153
158
mca_btl_tcp_endpoint_t * tcp_endpoint = endpoints [i ];
154
159
if (tcp_endpoint -> endpoint_proc != mca_btl_tcp_proc_local ()) {
@@ -157,6 +162,7 @@ int mca_btl_tcp_del_procs(struct mca_btl_base_module_t* btl,
157
162
}
158
163
opal_progress_event_users_decrement ();
159
164
}
165
+ OPAL_THREAD_UNLOCK (& tcp_btl -> tcp_endpoints_mutex );
160
166
return OPAL_SUCCESS ;
161
167
}
162
168
@@ -479,6 +485,10 @@ int mca_btl_tcp_finalize(struct mca_btl_base_module_t* btl)
479
485
{
480
486
mca_btl_tcp_module_t * tcp_btl = (mca_btl_tcp_module_t * ) btl ;
481
487
opal_list_item_t * item ;
488
+
489
+ /* Don't lock the tcp_endpoints_mutex, at this point a single
490
+ * thread should be active.
491
+ */
482
492
for ( item = opal_list_remove_first (& tcp_btl -> tcp_endpoints );
483
493
item != NULL ;
484
494
item = opal_list_remove_first (& tcp_btl -> tcp_endpoints )) {
@@ -512,11 +522,13 @@ void mca_btl_tcp_dump(struct mca_btl_base_module_t* base_btl,
512
522
} else if ( verbose ) {
513
523
opal_list_item_t * item ;
514
524
525
+ OPAL_THREAD_LOCK (& btl -> tcp_endpoints_mutex );
515
526
for (item = opal_list_get_first (& btl -> tcp_endpoints );
516
527
item != opal_list_get_end (& btl -> tcp_endpoints );
517
528
item = opal_list_get_next (item )) {
518
529
MCA_BTL_TCP_ENDPOINT_DUMP (10 , (mca_btl_base_endpoint_t * )item , false, "TCP" );
519
530
}
531
+ OPAL_THREAD_UNLOCK (& btl -> tcp_endpoints_mutex );
520
532
}
521
533
#endif /* OPAL_ENABLE_DEBUG && WANT_PEER_DUMP */
522
534
}
0 commit comments