net/rpmsg: simplify the socket timeout of connect

Signed-off-by: chao.an <anchao@xiaomi.com>
This commit is contained in:
chao.an 2021-08-16 17:16:17 +08:00 committed by Xiang Xiao
parent dc97ee9b36
commit 64e95dc1f5
1 changed files with 3 additions and 17 deletions

View File

@ -290,6 +290,8 @@ static int rpmsg_socket_sync(FAR struct rpmsg_socket_conn_s *conn,
return ret;
}
ret = OK;
if (conn->sendsize == 0)
{
ret = net_timedwait(&conn->sendsem, timeout);
@ -638,7 +640,6 @@ static int rpmsg_socket_listen(FAR struct socket *psock, int backlog)
static int rpmsg_socket_connect_internal(FAR struct socket *psock)
{
FAR struct rpmsg_socket_conn_s *conn = psock->s_conn;
unsigned int timeout;
unsigned int tc;
int ret;
@ -657,22 +658,7 @@ static int rpmsg_socket_connect_internal(FAR struct socket *psock)
return ret;
}
ret = -ETIMEDOUT;
timeout = _SO_TIMEOUT(psock->s_rcvtimeo);
for (tc = 0; tc < timeout * 1000; )
{
ret = rpmsg_socket_sync(conn, timeout);
if (ret != RPMSG_ERR_ADDR)
{
break;
}
if (timeout != UINT_MAX)
{
tc += RPMSG_TICK_COUNT;
}
}
ret = rpmsg_socket_sync(conn, _SO_TIMEOUT(psock->s_rcvtimeo));
if (ret < 0)
{