mirror of
https://github.com/apache/nuttx.git
synced 2026-10-12 00:30:23 +00:00
net/rpmsg: simplify the socket timeout of connect
Change-Id: I9ff5b3e7dad0b73196cfa058f3a55f2ea3086815 Signed-off-by: chao.an <anchao@xiaomi.com>
This commit is contained in:
parent
00b373112b
commit
79dd7453ac
1 changed files with 3 additions and 17 deletions
|
|
@ -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)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue