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 f965d3abaa4a19b8ced19415b06731e30d238851
Author: Yongrong Wang <[email protected]>
AuthorDate: Fri Oct 24 11:08:37 2025 +0800

    vsock_sockif.c: set the _SF_CLOSED flag when vsock_close is called
    
    Set the _SF_CLOSED flag to distinguish between gracefully
    disconnected or rudely disconnected to determine whether
    sub ref is needed
    
    Signed-off-by: Yongrong Wang <[email protected]>
---
 net/vsock/vsock_sockif.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/net/vsock/vsock_sockif.c b/net/vsock/vsock_sockif.c
index 53e7f2309f3..2a2978264f0 100644
--- a/net/vsock/vsock_sockif.c
+++ b/net/vsock/vsock_sockif.c
@@ -1368,7 +1368,10 @@ static void vsock_recv_closing(FAR struct vsock_conn_s 
*conn,
     {
       work_cancel_sync_wq(g_vsock_wqueue, &conn->close_work);
       vsock_remove_conn(conn);
-      vsock_sub_ref(conn);
+      if (_SS_ISCLOSED(conn->sconn.s_flags))
+        {
+          vsock_sub_ref(conn);
+        }
     }
 }
 
@@ -2137,6 +2140,8 @@ static int vsock_close(FAR struct socket *psock)
 
   vsock_lock(conn);
 
+  conn->sconn.s_flags |= _SF_CLOSED;
+
   /* Condition 1: socket()  created connection, bind or connect waiting
    * Condition 2: socket()  created connection, listen
    * Condition 3: accept()  created connection, must in connected state

Reply via email to