Skip to content

Commit 6b3be22

Browse files
committed
Adding a FIN message to differentiate normal TCP closing from failures
Signed-off-by: Aurelien Bouteiller <[email protected]>
1 parent b7be644 commit 6b3be22

File tree

3 files changed

+21
-3
lines changed

3 files changed

+21
-3
lines changed

opal/mca/btl/tcp/btl_tcp_endpoint.c

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
33
* University Research and Technology
44
* Corporation. All rights reserved.
5-
* Copyright (c) 2004-2017 The University of Tennessee and The University
5+
* Copyright (c) 2004-2020 The University of Tennessee and The University
66
* of Tennessee Research Foundation. All rights
77
* reserved.
88
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
@@ -535,6 +535,19 @@ void mca_btl_tcp_endpoint_close(mca_btl_base_endpoint_t* btl_endpoint)
535535
btl_endpoint->endpoint_cache_length = 0;
536536
#endif /* MCA_BTL_TCP_ENDPOINT_CACHE */
537537

538+
/* send a message before closing to differentiate between failures and
539+
* clean disconnect during finalize */
540+
if( MCA_BTL_TCP_CONNECTED == btl_endpoint->endpoint_state ) {
541+
mca_btl_tcp_hdr_t fin_msg = {
542+
.base.tag = 0,
543+
.type = MCA_BTL_TCP_HDR_TYPE_FIN,
544+
.count = 0,
545+
.size = 0,
546+
};
547+
mca_btl_tcp_endpoint_send_blocking(btl_endpoint,
548+
&fin_msg, sizeof(fin_msg));
549+
}
550+
538551
CLOSE_THE_SOCKET(btl_endpoint->endpoint_sd);
539552
btl_endpoint->endpoint_sd = -1;
540553
/**

opal/mca/btl/tcp/btl_tcp_frag.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
44
* University Research and Technology
55
* Corporation. All rights reserved.
6-
* Copyright (c) 2004-2016 The University of Tennessee and The University
6+
* Copyright (c) 2004-2020 The University of Tennessee and The University
77
* of Tennessee Research Foundation. All rights
88
* reserved.
99
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
@@ -273,6 +273,10 @@ bool mca_btl_tcp_frag_recv(mca_btl_tcp_frag_t* frag, int sd)
273273
if(frag->iov_cnt == 0) {
274274
if (btl_endpoint->endpoint_nbo && frag->iov_idx == 1) MCA_BTL_TCP_HDR_NTOH(frag->hdr);
275275
switch(frag->hdr.type) {
276+
case MCA_BTL_TCP_HDR_TYPE_FIN:
277+
frag->endpoint->endpoint_state = MCA_BTL_TCP_CLOSED;
278+
mca_btl_tcp_endpoint_close(frag->endpoint);
279+
break;
276280
case MCA_BTL_TCP_HDR_TYPE_SEND:
277281
if(frag->iov_idx == 1 && frag->hdr.size) {
278282
frag->segments[0].seg_addr.pval = frag+1;

opal/mca/btl/tcp/btl_tcp_hdr.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
33
* University Research and Technology
44
* Corporation. All rights reserved.
5-
* Copyright (c) 2004-2005 The University of Tennessee and The University
5+
* Copyright (c) 2004-2020 The University of Tennessee and The University
66
* of Tennessee Research Foundation. All rights
77
* reserved.
88
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
@@ -33,6 +33,7 @@ BEGIN_C_DECLS
3333
#define MCA_BTL_TCP_HDR_TYPE_SEND 1
3434
#define MCA_BTL_TCP_HDR_TYPE_PUT 2
3535
#define MCA_BTL_TCP_HDR_TYPE_GET 3
36+
#define MCA_BTL_TCP_HDR_TYPE_FIN 4
3637

3738
struct mca_btl_tcp_hdr_t {
3839
mca_btl_base_header_t base;

0 commit comments

Comments
 (0)