From 8d023cb97f79f27a2f5ba33341f9edccfcbf8cdf Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Thu, 19 Oct 2017 16:36:57 -0600 Subject: [PATCH] tcp_lost_connection() is called from two places in tcp_sendfile.c --- net/tcp/tcp_sendfile.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/net/tcp/tcp_sendfile.c b/net/tcp/tcp_sendfile.c index 3943c26489..6b7cb41a28 100644 --- a/net/tcp/tcp_sendfile.c +++ b/net/tcp/tcp_sendfile.c @@ -366,11 +366,25 @@ static uint16_t sendfile_eventhandler(FAR struct net_driver_s *dev, if ((flags & TCP_DISCONN_EVENTS) != 0) { + FAR struct socket *psock = pstate->snd_sock; + nwarn("WARNING: Lost connection\n"); + /* We could get here recursively through the callback actions of + * tcp_lost_connection(). So don't repeat that action if we have + * already been disconnected. + */ + + DEBUGASSERT(psock != NULL); + if (_SS_ISCONNECTED(psock->s_flags)) + { + /* Report not connected */ + + tcp_lost_connection(psock, pstate->snd_datacb, flags); + } + /* Report not connected */ - tcp_lost_connection(pstate->snd_sock, pstate->snd_datacb, flags); pstate->snd_sent = -ENOTCONN; goto end_wait; }