net/usrsock: Clear usockid when USRSOCK_EVENT_ABORT is received

When usrsock receives a USRSOCK_EVENT_ABORT, it determines that
the usrsock daemon's socket is closed. Then usrsock clears the usockid.
This commit is contained in:
SPRESENSE 2024-09-24 13:51:17 +09:00 committed by Xiang Xiao
parent e13d255345
commit 6a825f1ee7
4 changed files with 6 additions and 3 deletions

View file

@ -50,6 +50,8 @@
#define USRSOCK_EVENT_INTERNAL_MASK (USRSOCK_EVENT_CONNECT_READY | \
USRSOCK_EVENT_REQ_COMPLETE)
#define USRSOCK_USOCKID_INVALID (-1)
/****************************************************************************
* Public Type Definitions
****************************************************************************/

View file

@ -185,7 +185,7 @@ int usrsock_close(FAR struct usrsock_conn_s *conn)
close_out:
conn->state = USRSOCK_CONN_STATE_UNINITIALIZED;
conn->usockid = -1;
conn->usockid = USRSOCK_USOCKID_INVALID;
errout:
net_unlock();

View file

@ -117,7 +117,7 @@ FAR struct usrsock_conn_s *usrsock_alloc(void)
/* Make sure that the connection is marked as uninitialized */
nxsem_init(&conn->resp.sem, 0, 1);
conn->usockid = -1;
conn->usockid = USRSOCK_USOCKID_INVALID;
conn->state = USRSOCK_CONN_STATE_UNINITIALIZED;
/* Enqueue the connection into the active list */
@ -344,7 +344,7 @@ void usrsock_initialize(void)
/* Mark the connection closed and move it to the free list */
conn->usockid = -1;
conn->usockid = USRSOCK_USOCKID_INVALID;
conn->state = USRSOCK_CONN_STATE_UNINITIALIZED;
dq_addlast(&conn->sconn.node, &g_free_usrsock_connections);
}

View file

@ -87,6 +87,7 @@ int usrsock_event(FAR struct usrsock_conn_s *conn)
if (events & USRSOCK_EVENT_ABORT)
{
conn->state = USRSOCK_CONN_STATE_ABORTED;
conn->usockid = USRSOCK_USOCKID_INVALID;
}
if ((conn->state == USRSOCK_CONN_STATE_READY ||