net/tcp: Same change to tcp_send_buffered.c probably also applies to sixlowpan_tcpsend.c and inet_recvfrom.c

This commit is contained in:
Gregory Nutt 2017-10-19 16:45:00 -06:00
parent 8d023cb97f
commit 9e73216bf2
2 changed files with 31 additions and 6 deletions

View File

@ -735,11 +735,22 @@ static uint16_t inet_tcp_eventhandler(FAR struct net_driver_s *dev,
else if ((flags & TCP_DISCONN_EVENTS) != 0)
{
ninfo("Lost connection\n");
FAR struct socket *psock = pstate->ir_sock;
/* Handle loss-of-connection event */
nwarn("WARNING: Lost connection\n");
tcp_lost_connection(pstate->ir_sock, pstate->ir_cb, flags);
/* 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))
{
/* Handle loss-of-connection event */
tcp_lost_connection(psock, pstate->ir_cb, flags);
}
/* Check if the peer gracefully closed the connection. */

View File

@ -439,11 +439,25 @@ static uint16_t tcp_send_eventhandler(FAR struct net_driver_s *dev,
else if ((flags & TCP_DISCONN_EVENTS) != 0)
{
ninfo("Lost connection\n");
FAR struct socket *psock = sinfo->s_sock;
/* Report the disconnection event to all socket clones */
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 the disconnection event to all socket clones */
tcp_lost_connection(psock, sinfo->s_cb, flags);
}
/* Report not connected to the sender */
tcp_lost_connection(sinfo->s_sock, sinfo->s_cb, flags);
sinfo->s_result = -ENOTCONN;
goto end_wait;
}