From aa57fb159da6b20b9b11e79b0dc09e9340bc0826 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Sun, 14 May 2017 13:30:59 -0600 Subject: [PATCH] TCP: Send RST if applicaiton 'unlistens()' before we complete the connection sequence. --- net/tcp/tcp_input.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/net/tcp/tcp_input.c b/net/tcp/tcp_input.c index dc911bbf3f6..23bec6a6e55 100644 --- a/net/tcp/tcp_input.c +++ b/net/tcp/tcp_input.c @@ -486,10 +486,16 @@ found: nerr("Listen canceled while waiting for ACK on port %d\n", tcp->destport); + + /* Free the connection structure */ + conn->crefs = 0; tcp_free(conn); conn = NULL; - goto drop; + + /* And send a reset packet to the remote host. */ + + goto reset; } #ifdef CONFIG_NET_TCP_WRITE_BUFFERS