From 3e230ca9eb597fb6ad70acd2dd527037b43a68e0 Mon Sep 17 00:00:00 2001 From: Xiang Xiao Date: Fri, 17 Jan 2020 09:26:47 -0800 Subject: [PATCH] net/inet/inet_recvfrom.c: Correct the return value (#121) NuttX follows OpenGroup.org: https://pubs.opengroup.org/onlinepubs/009695399/functions/recv.html : [EAGAIN] or [EWOULDBLOCK] The socket's file descriptor is marked O_NONBLOCK and no data is waiting to be received; or MSG_OOB is set and no out-of-band data is available and either the socket's file descriptor is marked O_NONBLOCK or the socket does not support blocking to await out-of-band data. ETIMEDOUT is not a valid error to be returned from recv() or recvfrom(). --- net/inet/inet_recvfrom.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/net/inet/inet_recvfrom.c b/net/inet/inet_recvfrom.c index b217cca0f6..7d56b54ebd 100644 --- a/net/inet/inet_recvfrom.c +++ b/net/inet/inet_recvfrom.c @@ -1086,6 +1086,10 @@ static ssize_t inet_udp_recvfrom(FAR struct socket *psock, FAR void *buf, size_t */ ret = net_timedwait(&state. ir_sem, _SO_TIMEOUT(psock->s_rcvtimeo)); + if (ret == -ETIMEDOUT) + { + ret = -EAGAIN; + } /* Make sure that no further events are processed */ @@ -1236,6 +1240,10 @@ static ssize_t inet_tcp_recvfrom(FAR struct socket *psock, FAR void *buf, size_t */ ret = net_timedwait(&state.ir_sem, _SO_TIMEOUT(psock->s_rcvtimeo)); + if (ret == -ETIMEDOUT) + { + ret = -EAGAIN; + } /* Make sure that no further events are processed */