diff --git a/net/local/local.h b/net/local/local.h index ca9eab2d16..9af3a5139d 100644 --- a/net/local/local.h +++ b/net/local/local.h @@ -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 diff --git a/net/local/local_accept.c b/net/local/local_accept.c index 5a2bed225d..6cf82c69ca 100644 --- a/net/local/local_accept.c +++ b/net/local/local_accept.c @@ -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; } diff --git a/net/local/local_conn.c b/net/local/local_conn.c index 302c7cb848..2e343bb630 100644 --- a/net/local/local_conn.c +++ b/net/local/local_conn.c @@ -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 */ diff --git a/net/local/local_connect.c b/net/local/local_connect.c index 37181ddd30..74aede5da0 100644 --- a/net/local/local_connect.c +++ b/net/local/local_connect.c @@ -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;