local: server accept should wait client connect done
server: at accept last nxsem_post(&client->lc_waitsem); client: connect wait(&client->lc_waitsem) then local_open_client_rx(); But if the server priority is higher then client, and after server accept return, immediately call send(). At this time the client has no way do local_open_client_rx(). Then server send() return error. Fix: add lc_done sem to client Signed-off-by: ligd <liguiding1@xiaomi.com>
This commit is contained in:
parent
e489a308c8
commit
cd5ab80f2f
|
@ -145,6 +145,7 @@ struct local_conn_s
|
|||
/* SOCK_STREAM fields common to both client and server */
|
||||
|
||||
sem_t lc_waitsem; /* Use to wait for a connection to be accepted */
|
||||
sem_t lc_donesem; /* Use to wait for client connected done */
|
||||
FAR struct socket *lc_psock; /* A reference to the socket structure */
|
||||
|
||||
/* The following is a list if poll structures of threads waiting for
|
||||
|
|
|
@ -243,6 +243,12 @@ int local_accept(FAR struct socket *psock, FAR struct sockaddr *addr,
|
|||
}
|
||||
|
||||
nxsem_post(&client->lc_waitsem);
|
||||
|
||||
if (ret == OK)
|
||||
{
|
||||
ret = net_lockedwait(&client->lc_donesem);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
|
@ -124,6 +124,10 @@ FAR struct local_conn_s *local_alloc(void)
|
|||
|
||||
nxsem_init(&conn->lc_waitsem, 0, 0);
|
||||
nxsem_set_protocol(&conn->lc_waitsem, SEM_PRIO_NONE);
|
||||
|
||||
nxsem_init(&conn->lc_donesem, 0, 0);
|
||||
nxsem_set_protocol(&conn->lc_donesem, SEM_PRIO_NONE);
|
||||
|
||||
#endif
|
||||
|
||||
/* Add the connection structure to the list of listeners */
|
||||
|
@ -203,6 +207,7 @@ void local_free(FAR struct local_conn_s *conn)
|
|||
|
||||
local_release_fifos(conn);
|
||||
nxsem_destroy(&conn->lc_waitsem);
|
||||
nxsem_destroy(&conn->lc_donesem);
|
||||
#endif
|
||||
|
||||
/* And free the connection structure */
|
||||
|
|
|
@ -178,6 +178,8 @@ static int inline local_stream_connect(FAR struct local_conn_s *client,
|
|||
|
||||
DEBUGASSERT(client->lc_infile.f_inode != NULL);
|
||||
|
||||
nxsem_post(&client->lc_donesem);
|
||||
|
||||
if (!nonblock)
|
||||
{
|
||||
client->lc_state = LOCAL_STATE_CONNECTED;
|
||||
|
|
Loading…
Reference in New Issue