From b400b99001f922fb936314878effd2a8c4393afa Mon Sep 17 00:00:00 2001 From: Xiang Xiao Date: Thu, 8 Sep 2022 16:57:29 +0800 Subject: [PATCH] net/usrsock: Simplify the return value process of net_timedwait Signed-off-by: Xiang Xiao --- net/usrsock/usrsock_accept.c | 8 +------- net/usrsock/usrsock_recvmsg.c | 8 +------- net/usrsock/usrsock_sendmsg.c | 8 +------- 3 files changed, 3 insertions(+), 21 deletions(-) diff --git a/net/usrsock/usrsock_accept.c b/net/usrsock/usrsock_accept.c index d011b82a95..64be6e0e48 100644 --- a/net/usrsock/usrsock_accept.c +++ b/net/usrsock/usrsock_accept.c @@ -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; } diff --git a/net/usrsock/usrsock_recvmsg.c b/net/usrsock/usrsock_recvmsg.c index 68ea6342d3..e3881ac097 100644 --- a/net/usrsock/usrsock_recvmsg.c +++ b/net/usrsock/usrsock_recvmsg.c @@ -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; } diff --git a/net/usrsock/usrsock_sendmsg.c b/net/usrsock/usrsock_sendmsg.c index 255dd80a7a..f8c6ef9e0c 100644 --- a/net/usrsock/usrsock_sendmsg.c +++ b/net/usrsock/usrsock_sendmsg.c @@ -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; }