mirror of
https://github.com/apache/nuttx.git
synced 2026-06-07 09:18:00 +08:00
TCP: attempt to flush the write buffers before closing
When a socket is closed, it should make sure that any pending write data is sent before the FIN is sent. It already would wait for all sent data to be acked, however it would discard any pending write data that had not been sent at least once. This change adds a check for pending write data in addition to unacked data. However, to be able to actually send any new data, the send callback must be left. The callback should be freed later when the socket is actually destroyed.
This commit is contained in:
committed by
Gregory Nutt
parent
cdd187a7f3
commit
f1ef2c6cde
@@ -223,7 +223,7 @@ static uint16_t netclose_interrupt(FAR struct net_driver_s *dev,
|
||||
#ifdef CONFIG_NET_TCP_WRITE_BUFFERS
|
||||
/* Check if all outstanding bytes have been ACKed */
|
||||
|
||||
else if (conn->unacked != 0)
|
||||
else if (conn->unacked != 0 || !sq_empty(&conn->write_q))
|
||||
{
|
||||
/* No... we are still waiting for ACKs. Drop any received data, but
|
||||
* do not yet report TCP_CLOSE in the response.
|
||||
@@ -357,14 +357,11 @@ static inline int netclose_disconnect(FAR struct socket *psock)
|
||||
#ifdef CONFIG_NET_TCP_WRITE_BUFFERS
|
||||
if (psock->s_sndcb)
|
||||
{
|
||||
tcp_callback_free(conn, psock->s_sndcb);
|
||||
psock->s_sndcb = NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* There shouldn't be any callbacks registered. */
|
||||
|
||||
DEBUGASSERT(conn && conn->list == NULL);
|
||||
DEBUGASSERT(conn != NULL);
|
||||
|
||||
/* Check for the case where the host beat us and disconnected first */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user