mirror of
https://github.com/apache/nuttx.git
synced 2026-05-27 19:36:35 +08:00
net/usrsock/usrsock_accept.c: Mark newconn ready before issue accept request to avoid the event get discarded due to the socket in the invalid state
This commit is contained in:
@@ -421,6 +421,11 @@ int usrsock_accept(FAR struct socket *psock, FAR struct sockaddr *addr,
|
|||||||
|
|
||||||
usrsock_setup_datain(conn, inbufs, ARRAY_SIZE(inbufs));
|
usrsock_setup_datain(conn, inbufs, ARRAY_SIZE(inbufs));
|
||||||
|
|
||||||
|
/* We might start getting events for this socket right after
|
||||||
|
* returning to daemon, so setup 'newconn' already here. */
|
||||||
|
|
||||||
|
newconn->state = USRSOCK_CONN_STATE_READY;
|
||||||
|
|
||||||
/* Request user-space daemon to accept socket. */
|
/* Request user-space daemon to accept socket. */
|
||||||
|
|
||||||
ret = do_accept_request(conn, inaddrlen);
|
ret = do_accept_request(conn, inaddrlen);
|
||||||
@@ -440,7 +445,6 @@ int usrsock_accept(FAR struct socket *psock, FAR struct sockaddr *addr,
|
|||||||
|
|
||||||
if (ret >= 0)
|
if (ret >= 0)
|
||||||
{
|
{
|
||||||
newconn->state = USRSOCK_CONN_STATE_READY;
|
|
||||||
newconn->connected = true;
|
newconn->connected = true;
|
||||||
newconn->type = conn->type;
|
newconn->type = conn->type;
|
||||||
newconn->crefs = 1;
|
newconn->crefs = 1;
|
||||||
|
|||||||
Reference in New Issue
Block a user