casaroli commented on code in PR #21403:
URL: https://github.com/apache/nuttx/pull/21403#discussion_r4469345723
##########
net/rpmsg/rpmsg_sockif.c:
##########
@@ -588,15 +732,52 @@ static void rpmsg_socket_ns_bind(FAR struct rpmsg_device
*rdev,
return;
}
+ new->server = server;
+ new->priority = server->priority;
new->ept.priv = new;
new->ept.release_cb = rpmsg_socket_ept_release;
+
+ /* Take the backlog slot and join the listener's pending list before the
+ * endpoint exists. rpmsg_create_ept() sends the NS ack, after which the
+ * remote may answer with its SYNC at once; the handler must already be
+ * able to find this connection on the list.
+ */
+
+ nxmutex_lock(&server->recvlock);
+ if (server->pending >= server->backlog)
+ {
+ /* Reject the connection */
+
+ nerr("Reject the connection, Max listen %d\n", server->backlog);
+ nxmutex_unlock(&server->recvlock);
+ rpmsg_socket_free(new);
Review Comment:
A client that connects to a full backlog now waits forever. The endpoint
does not exist here, so no NS_DESTROY goes to the client. qemu-armv8a:rpserver
and rpproxy, listen(fd, 1), no accept(), second connect(): master ECONNRESET
after 6 ms, this PR ETIMEDOUT after the full 10 s SO_SNDTIMEO.
Fix: in this path, set `new->server = NULL`, call `rpmsg_create_ept()`, then
`rpmsg_destroy_ept(&new->ept)`, then `rpmsg_socket_free(new)`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]