usrsock: fix usrsock close hang when net not ready

reason: ept NULL when close request and poll event occur simultaneously

Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
This commit is contained in:
zhanghongyu 2022-04-07 19:33:38 +08:00 committed by Petro Karashchenko
parent 451243accb
commit 26892be894

View File

@ -284,12 +284,12 @@ static int usrsock_rpmsg_close_handler(struct rpmsg_endpoint *ept,
if (req->usockid >= 0 &&
req->usockid < CONFIG_NETUTILS_USRSOCK_NSOCK_DESCRIPTORS)
{
pthread_mutex_lock(&priv->mutex);
priv->pfds[req->usockid].ptr = NULL;
priv->epts[req->usockid] = NULL;
/* Signal and wait the poll thread to wakeup */
pthread_mutex_lock(&priv->mutex);
usrsock_rpmsg_notify_poll(priv);
pthread_cond_wait(&priv->cond, &priv->mutex);
pthread_mutex_unlock(&priv->mutex);