49
49
#include "opal/util/show_help.h"
50
50
51
51
#include "btl_tcp_frag.h"
52
+ #include "btl_tcp_proc.h"
52
53
#include "btl_tcp_endpoint.h"
53
54
#include "btl_tcp_proc.h"
54
55
@@ -130,13 +131,15 @@ bool mca_btl_tcp_frag_send(mca_btl_tcp_frag_t* frag, int sd)
130
131
BTL_ERROR (("mca_btl_tcp_frag_send: writev error (%p, %lu)\n\t%s(%lu)\n" ,
131
132
frag -> iov_ptr [0 ].iov_base , (unsigned long ) frag -> iov_ptr [0 ].iov_len ,
132
133
strerror (opal_socket_errno ), (unsigned long ) frag -> iov_cnt ));
134
+ /* send_lock held by caller */
133
135
frag -> endpoint -> endpoint_state = MCA_BTL_TCP_FAILED ;
134
136
mca_btl_tcp_endpoint_close (frag -> endpoint );
135
137
return false;
136
138
default :
137
139
BTL_ERROR (("mca_btl_tcp_frag_send: writev failed: %s (%d)" ,
138
140
strerror (opal_socket_errno ),
139
141
opal_socket_errno ));
142
+ /* send_lock held by caller */
140
143
frag -> endpoint -> endpoint_state = MCA_BTL_TCP_FAILED ;
141
144
mca_btl_tcp_endpoint_close (frag -> endpoint );
142
145
return false;
@@ -215,9 +218,11 @@ bool mca_btl_tcp_frag_recv(mca_btl_tcp_frag_t* frag, int sd)
215
218
cnt = readv (sd , frag -> iov_ptr , num_vecs );
216
219
if ( 0 < cnt ) goto advance_iov_position ;
217
220
if ( cnt == 0 ) {
221
+ OPAL_THREAD_LOCK (& btl_endpoint -> endpoint_send_lock );
218
222
if (MCA_BTL_TCP_CONNECTED == btl_endpoint -> endpoint_state )
219
223
btl_endpoint -> endpoint_state = MCA_BTL_TCP_FAILED ;
220
224
mca_btl_tcp_endpoint_close (btl_endpoint );
225
+ OPAL_THREAD_UNLOCK (& btl_endpoint -> endpoint_send_lock );
221
226
return false;
222
227
}
223
228
switch (opal_socket_errno ) {
@@ -229,28 +234,25 @@ bool mca_btl_tcp_frag_recv(mca_btl_tcp_frag_t* frag, int sd)
229
234
BTL_ERROR (("mca_btl_tcp_frag_recv: readv error (%p, %lu)\n\t%s(%lu)\n" ,
230
235
frag -> iov_ptr [0 ].iov_base , (unsigned long ) frag -> iov_ptr [0 ].iov_len ,
231
236
strerror (opal_socket_errno ), (unsigned long ) frag -> iov_cnt ));
232
- btl_endpoint -> endpoint_state = MCA_BTL_TCP_FAILED ;
233
- mca_btl_tcp_endpoint_close (btl_endpoint );
234
- return false;
235
-
237
+ break ;
236
238
case ECONNRESET :
237
239
errhost = opal_get_proc_hostname (btl_endpoint -> endpoint_proc -> proc_opal );
238
240
opal_show_help ("help-mpi-btl-tcp.txt" , "peer hung up" ,
239
241
true, opal_process_info .nodename ,
240
242
getpid (), errhost );
241
243
free (errhost );
242
- btl_endpoint -> endpoint_state = MCA_BTL_TCP_FAILED ;
243
- mca_btl_tcp_endpoint_close (btl_endpoint );
244
- return false;
245
-
244
+ break ;
246
245
default :
247
246
BTL_ERROR (("mca_btl_tcp_frag_recv: readv failed: %s (%d)" ,
248
247
strerror (opal_socket_errno ),
249
248
opal_socket_errno ));
250
- btl_endpoint -> endpoint_state = MCA_BTL_TCP_FAILED ;
251
- mca_btl_tcp_endpoint_close (btl_endpoint );
252
- return false;
249
+ break ;
253
250
}
251
+ OPAL_THREAD_LOCK (& btl_endpoint -> endpoint_send_lock );
252
+ btl_endpoint -> endpoint_state = MCA_BTL_TCP_FAILED ;
253
+ mca_btl_tcp_endpoint_close (btl_endpoint );
254
+ OPAL_THREAD_UNLOCK (& btl_endpoint -> endpoint_send_lock );
255
+ return false;
254
256
} while ( cnt < 0 );
255
257
256
258
advance_iov_position :
0 commit comments