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 890f2616a1e0a0b1fc67440b9e90175732c9ab23
Author: Bowen Wang <[email protected]>
AuthorDate: Mon Jun 22 23:01:15 2026 +0800

    net/rpmsg: clear a stale unbind flag when SYNC arrives
    
    A NS_DESTROY from the peer sets conn->unbind but does not destroy the
    endpoint, so a later SYNC still arrives and marks the socket connected.
    connect() however kept seeing unbind set and failed, the application
    closed the socket and the peer was left with a connection nobody used.
    
    The SYNC proves that the peer has re-established the connection, so
    clear conn->unbind there.
    
    Signed-off-by: Bowen Wang <[email protected]>
---
 net/rpmsg/rpmsg_sockif.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/net/rpmsg/rpmsg_sockif.c b/net/rpmsg/rpmsg_sockif.c
index a9d7d20cd17..83a15cbd3db 100644
--- a/net/rpmsg/rpmsg_sockif.c
+++ b/net/rpmsg/rpmsg_sockif.c
@@ -382,6 +382,12 @@ static int rpmsg_socket_ept_cb(FAR struct rpmsg_endpoint 
*ept,
       conn->sconn.s_flags |= _SF_CONNECTED;
       _SO_CONN_SETERRNO(conn, OK);
 
+      /* SYNC means the peer (re)established the connection.  Clear any
+       * stale unbind flag left by a previous NS_DESTROY so that connect()
+       * does not wrongly fail.
+       */
+
+      atomic_set_release(&conn->unbind, 0);
       rpmsg_socket_post(&conn->sendsem);
       rpmsg_socket_poll_notify(conn, POLLOUT);
       nxmutex_unlock(&conn->sendlock);

Reply via email to