Skip to content

Commit

Permalink
net/tcp: Same change to tcp_send_buffered.c probably also applies to …
Browse files Browse the repository at this point in the history
…sixlowpan_tcpsend.c and inet_recvfrom.c
  • Loading branch information
gregory-nutt committed Oct 19, 2017
1 parent 8d023cb commit 9e73216
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 6 deletions.
17 changes: 14 additions & 3 deletions net/inet/inet_recvfrom.c
Original file line number Diff line number Diff line change
Expand Up @@ -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. */

Expand Down
20 changes: 17 additions & 3 deletions net/sixlowpan/sixlowpan_tcpsend.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 9e73216

Please sign in to comment.