net/local: add local_nextconn() helper
Signed-off-by: chao.an <anchao@xiaomi.com>
This commit is contained in:
parent
9d0da9818c
commit
805d3a2061
@ -255,6 +255,19 @@ FAR struct local_conn_s *local_alloc(void);
|
||||
|
||||
void local_free(FAR struct local_conn_s *conn);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: local_nextconn
|
||||
*
|
||||
* Description:
|
||||
* Traverse the list of allocated Local connections
|
||||
*
|
||||
* Assumptions:
|
||||
* Called from network stack logic with the network stack locked
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
FAR struct local_conn_s *local_nextconn(FAR struct local_conn_s *conn);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: psock_local_bind
|
||||
*
|
||||
|
@ -55,6 +55,33 @@ void local_initialize(void)
|
||||
#endif
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: local_nextconn
|
||||
*
|
||||
* Description:
|
||||
* Traverse the list of listened local connections
|
||||
*
|
||||
* Assumptions:
|
||||
* This function must be called with the network locked.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
FAR struct local_conn_s *local_nextconn(FAR struct local_conn_s *conn)
|
||||
{
|
||||
#ifdef CONFIG_NET_LOCAL_STREAM
|
||||
if (!conn)
|
||||
{
|
||||
return (FAR struct local_conn_s *)g_local_listeners.head;
|
||||
}
|
||||
else
|
||||
{
|
||||
return (FAR struct local_conn_s *)conn->lc_node.flink;
|
||||
}
|
||||
#else
|
||||
return NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: local_alloc()
|
||||
*
|
||||
|
@ -242,7 +242,7 @@ int psock_local_connect(FAR struct socket *psock,
|
||||
{
|
||||
FAR struct local_conn_s *client;
|
||||
FAR struct sockaddr_un *unaddr = (FAR struct sockaddr_un *)addr;
|
||||
FAR struct local_conn_s *conn;
|
||||
FAR struct local_conn_s *conn = NULL;
|
||||
|
||||
DEBUGASSERT(psock && psock->s_conn);
|
||||
client = (FAR struct local_conn_s *)psock->s_conn;
|
||||
@ -256,9 +256,7 @@ int psock_local_connect(FAR struct socket *psock,
|
||||
/* Find the matching server connection */
|
||||
|
||||
net_lock();
|
||||
for (conn = (FAR struct local_conn_s *)g_local_listeners.head;
|
||||
conn;
|
||||
conn = (FAR struct local_conn_s *)dq_next(&conn->lc_node))
|
||||
while ((conn = local_nextconn(conn)) != NULL)
|
||||
{
|
||||
/* Anything in the listener list should be a stream socket in the
|
||||
* listening state
|
||||
|
Loading…
Reference in New Issue
Block a user