This is an automated email from the ASF dual-hosted git repository.
GUIDINGLI pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
The following commit(s) were added to refs/heads/master by this push:
new 4098dff315f net/rpmsg: report a rejected connect via SO_ERROR
4098dff315f is described below
commit 4098dff315f1f83734e1d4d95042ff2de4239538
Author: cenzhanquan1 <[email protected]>
AuthorDate: Thu Nov 26 10:13:01 2026 +0800
net/rpmsg: report a rejected connect via SO_ERROR
When the peer rejects a pending connect with NS_DESTROY because no
server is listening yet, ns_unbind wakes the waiter but leaves s_error
at 0. A non-blocking connect that reads SO_ERROR after poll (e.g.
libuv) then treats the rejected connect as established. Set ECONNRESET
while the socket is still connecting, the same result a blocking
connect returns.
Signed-off-by: cenzhanquan1 <[email protected]>
Signed-off-by: Bowen Wang <[email protected]>
---
net/rpmsg/rpmsg_sockif.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/net/rpmsg/rpmsg_sockif.c b/net/rpmsg/rpmsg_sockif.c
index a9b55717298..e1f41a8a15f 100644
--- a/net/rpmsg/rpmsg_sockif.c
+++ b/net/rpmsg/rpmsg_sockif.c
@@ -705,6 +705,19 @@ static void rpmsg_socket_ns_unbind(FAR struct
rpmsg_endpoint *ept)
FAR struct rpmsg_socket_conn_s *server;
irqstate_t flags;
+ /* A non-blocking connect learns the result from SO_ERROR once polled,
+ * so a peer that rejects the pending connect (NS_DESTROY, no server
+ * listening yet) must leave an error there.
+ */
+
+ flags = spin_lock_irqsave_nopreempt(&conn->sendlock);
+ if (_SS_ISCONNECTING(conn->sconn.s_flags))
+ {
+ _SO_CONN_SETERRNO(conn, ECONNRESET);
+ }
+
+ spin_unlock_irqrestore_nopreempt(&conn->sendlock, flags);
+
flags = spin_lock_irqsave_nopreempt(&conn->recvlock);
server = conn->server;
conn->server = NULL;