Skip to content

Commit 6a825f1

Browse files
SPRESENSExiaoxiang781216
authored andcommitted
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.
1 parent e13d255 commit 6a825f1

File tree

4 files changed

+6
-3
lines changed

4 files changed

+6
-3
lines changed

net/usrsock/usrsock.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@
5050
#define USRSOCK_EVENT_INTERNAL_MASK (USRSOCK_EVENT_CONNECT_READY | \
5151
USRSOCK_EVENT_REQ_COMPLETE)
5252

53+
#define USRSOCK_USOCKID_INVALID (-1)
54+
5355
/****************************************************************************
5456
* Public Type Definitions
5557
****************************************************************************/

net/usrsock/usrsock_close.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ int usrsock_close(FAR struct usrsock_conn_s *conn)
185185

186186
close_out:
187187
conn->state = USRSOCK_CONN_STATE_UNINITIALIZED;
188-
conn->usockid = -1;
188+
conn->usockid = USRSOCK_USOCKID_INVALID;
189189

190190
errout:
191191
net_unlock();

net/usrsock/usrsock_conn.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ FAR struct usrsock_conn_s *usrsock_alloc(void)
117117
/* Make sure that the connection is marked as uninitialized */
118118

119119
nxsem_init(&conn->resp.sem, 0, 1);
120-
conn->usockid = -1;
120+
conn->usockid = USRSOCK_USOCKID_INVALID;
121121
conn->state = USRSOCK_CONN_STATE_UNINITIALIZED;
122122

123123
/* Enqueue the connection into the active list */
@@ -344,7 +344,7 @@ void usrsock_initialize(void)
344344

345345
/* Mark the connection closed and move it to the free list */
346346

347-
conn->usockid = -1;
347+
conn->usockid = USRSOCK_USOCKID_INVALID;
348348
conn->state = USRSOCK_CONN_STATE_UNINITIALIZED;
349349
dq_addlast(&conn->sconn.node, &g_free_usrsock_connections);
350350
}

net/usrsock/usrsock_event.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ int usrsock_event(FAR struct usrsock_conn_s *conn)
8787
if (events & USRSOCK_EVENT_ABORT)
8888
{
8989
conn->state = USRSOCK_CONN_STATE_ABORTED;
90+
conn->usockid = USRSOCK_USOCKID_INVALID;
9091
}
9192

9293
if ((conn->state == USRSOCK_CONN_STATE_READY ||

0 commit comments

Comments
 (0)