This is an automated email from the ASF dual-hosted git repository.

xiaoxiang781216 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git

commit 80606dc2675e4b9cda9548463a8cef1436f176ed
Author: wenquan1 <[email protected]>
AuthorDate: Thu Oct 9 14:14:59 2025 +0800

    net/tcp: directly send RST when SO_LINGER is set and l_linger is 0
    
    When SO_LINGER is enabled with l_linger set to 0, close() must abort
    the connection immediately instead of going through the normal FIN
    handshake.  Send a RST at once and release the connection rather than
    starting the graceful-close timer.
    
    Signed-off-by: wenquan1 <[email protected]>
---
 net/tcp/tcp_close.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/net/tcp/tcp_close.c b/net/tcp/tcp_close.c
index 1a80373e3e9..3ba69207ce4 100644
--- a/net/tcp/tcp_close.c
+++ b/net/tcp/tcp_close.c
@@ -283,7 +283,18 @@ static inline int tcp_close_disconnect(FAR struct socket 
*psock)
 
           /* Update RTO timeout if the work exceeds expire */
 
-          tcp_update_timer(conn);
+          if (conn->sconn.s_linger == 0)
+            {
+              /* Directly set timeout to avoid the priority of the
+               * schedule tcp_timer_expiry and tcp_send_txnotify
+               */
+
+              conn->timeout = true;
+            }
+          else
+            {
+              tcp_update_timer(conn);
+            }
         }
 #endif
 

Reply via email to