From 49e5cc5a6fa19460b41c8667d67b912d6f71affe Mon Sep 17 00:00:00 2001 From: Andrew Webster Date: Fri, 22 Jan 2016 16:22:09 -0600 Subject: [PATCH] TCP: check for an active connection before cleaning it up If there is no active connection (e.g. it is waiting in accept), then the connection object, which doesn't yet exist, should not be cleaned up when the socket is closed. --- net/tcp/tcp_send_buffered.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/net/tcp/tcp_send_buffered.c b/net/tcp/tcp_send_buffered.c index 1d560c7e893..077a1dbe2e0 100644 --- a/net/tcp/tcp_send_buffered.c +++ b/net/tcp/tcp_send_buffered.c @@ -507,9 +507,12 @@ static uint16_t psock_send_interrupt(FAR struct net_driver_s *dev, { nllvdbg("Lost connection: %04x\n", flags); - /* Report not connected */ + if (psock->s_conn != NULL) + { + /* Report not connected */ - net_lostconnection(psock, flags); + net_lostconnection(psock, flags); + } /* Free write buffers and terminate polling */