This is an automated email from the ASF dual-hosted git repository. xiaoxiang pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx.git
The following commit(s) were added to refs/heads/master by this push: new 49dbe7e177 rpmsg_sockif: add recvlock for conn->sendsize in connect 49dbe7e177 is described below commit 49dbe7e177e6a4520ad83f9d84753eb440e883dc Author: Bowen Wang <wangbow...@xiaomi.com> AuthorDate: Mon Aug 28 14:09:09 2023 +0800 rpmsg_sockif: add recvlock for conn->sendsize in connect conn->sendsize is used in rpmsg_socket_ept_cb() and rpmsg_socket_connect_internal(), the connected event may be missed as stated below: 1. in rpmsg_socket_connect_internal(), judge conn->sendsize == 0 and prepare to wait sendsem; 2. interrupt by rptun thread, rpmsg_socket_ept_cb() is called to update conn->sendsize and post the sendsem, but the no one wait rx sem yet, so not post (see rpmsg_socket_post()); 3. return to rpmsg_socket_connect_internal() to wait the sendsem, but has miss the connected event. So add recvlock in rpmsg_socket_connect_internal() also. Signed-off-by: Bowen Wang <wangbow...@xiaomi.com> --- net/rpmsg/rpmsg_sockif.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/net/rpmsg/rpmsg_sockif.c b/net/rpmsg/rpmsg_sockif.c index 10b67d2f61..72d338d6e2 100644 --- a/net/rpmsg/rpmsg_sockif.c +++ b/net/rpmsg/rpmsg_sockif.c @@ -717,8 +717,10 @@ static int rpmsg_socket_connect_internal(FAR struct socket *psock) return ret; } + nxmutex_lock(&conn->recvlock); if (conn->sendsize == 0) { + nxmutex_unlock(&conn->recvlock); if (_SS_ISNONBLOCK(conn->sconn.s_flags)) { return -EINPROGRESS; @@ -736,6 +738,10 @@ static int rpmsg_socket_connect_internal(FAR struct socket *psock) NULL); } } + else + { + nxmutex_unlock(&conn->recvlock); + } return ret; }