diff --git a/components/net/at/at_socket/at_socket.c b/components/net/at/at_socket/at_socket.c index 2973120205..4c5dee2b62 100644 --- a/components/net/at/at_socket/at_socket.c +++ b/components/net/at/at_socket/at_socket.c @@ -1065,13 +1065,6 @@ int at_recvfrom(int socket, void *mem, size_t len, int flags, struct sockaddr *f while (1) { - if (sock->state == AT_SOCKET_CLOSED) - { - /* socket passively closed, receive function return 0 */ - result = 0; - goto __exit; - } - /* receive packet list last transmission of remaining data */ rt_mutex_take(sock->recv_lock, RT_WAITING_FOREVER); recv_len = at_recvpkt_get(&(sock->recvpkt_list), (char *)mem, len); @@ -1086,6 +1079,13 @@ int at_recvfrom(int socket, void *mem, size_t len, int flags, struct sockaddr *f goto __exit; } + if (sock->state == AT_SOCKET_CLOSED) + { + /* socket passively closed, receive function return 0 */ + result = 0; + goto __exit; + } + if (flags & MSG_DONTWAIT) { rt_set_errno(EAGAIN);