net/usrsock: Simplify the return value process of net_timedwait

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
Xiang Xiao 2022-09-08 16:57:29 +08:00 committed by Masayuki Ishikawa
parent 77823415ed
commit b400b99001
3 changed files with 3 additions and 21 deletions

View File

@ -328,6 +328,7 @@ int usrsock_accept(FAR struct socket *psock, FAR struct sockaddr *addr,
ret = net_timedwait(&state.reqstate.recvsem,
_SO_TIMEOUT(conn->sconn.s_rcvtimeo));
usrsock_teardown_data_request_callback(&state);
if (ret < 0)
{
if (ret == -ETIMEDOUT)
@ -345,14 +346,7 @@ int usrsock_accept(FAR struct socket *psock, FAR struct sockaddr *addr,
nerr("net_timedwait errno: %d\n", ret);
DEBUGPANIC();
}
}
usrsock_teardown_data_request_callback(&state);
/* Did wait timeout or got signal? */
if (ret != 0)
{
goto errout_free_conn;
}

View File

@ -326,6 +326,7 @@ ssize_t usrsock_recvmsg(FAR struct socket *psock, FAR struct msghdr *msg,
ret = net_timedwait(&state.reqstate.recvsem,
_SO_TIMEOUT(conn->sconn.s_rcvtimeo));
usrsock_teardown_data_request_callback(&state);
if (ret < 0)
{
if (ret == -ETIMEDOUT)
@ -343,14 +344,7 @@ ssize_t usrsock_recvmsg(FAR struct socket *psock, FAR struct msghdr *msg,
nerr("net_timedwait errno: %zd\n", ret);
DEBUGPANIC();
}
}
usrsock_teardown_data_request_callback(&state);
/* Did wait timeout or got signal? */
if (ret != 0)
{
goto errout_unlock;
}

View File

@ -308,6 +308,7 @@ ssize_t usrsock_sendmsg(FAR struct socket *psock,
ret = net_timedwait(&state.recvsem,
_SO_TIMEOUT(conn->sconn.s_sndtimeo));
usrsock_teardown_request_callback(&state);
if (ret < 0)
{
if (ret == -ETIMEDOUT)
@ -325,14 +326,7 @@ ssize_t usrsock_sendmsg(FAR struct socket *psock,
nerr("net_timedwait errno: %zd\n", ret);
DEBUGPANIC();
}
}
usrsock_teardown_request_callback(&state);
/* Did wait timeout or got signal? */
if (ret != 0)
{
goto errout_unlock;
}