This is an automated email from the ASF dual-hosted git repository. acassis pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit 41f10558f395bd7b5c2c0ecc6d17e8a71128b610 Author: Marco Casaroli <[email protected]> AuthorDate: Thu Nov 19 07:10:59 2026 +0100 net/pkt: Use the receive timeout of the socket in recvmsg(). pkt_recvmsg() waited for a frame with no timeout and did not read the SO_RCVTIMEO value of the socket. A recv() on an idle packet socket with a receive timeout blocked until a frame or a signal came. pkt_recvmsg() now waits with the receive timeout of the socket, as the UDP and ICMP receive operations do. On a timeout it returns EAGAIN. If a frame comes after the timeout and before the wait gets the lock again, the frame is kept and returned. Assisted-by: Claude Code:claude-opus-5-5 Signed-off-by: Marco Casaroli <[email protected]> --- net/pkt/pkt_recvmsg.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/net/pkt/pkt_recvmsg.c b/net/pkt/pkt_recvmsg.c index c4660b8ad29..7f331fc9baf 100644 --- a/net/pkt/pkt_recvmsg.c +++ b/net/pkt/pkt_recvmsg.c @@ -647,8 +647,17 @@ ssize_t pkt_recvmsg(FAR struct socket *psock, FAR struct msghdr *msg, * the task restarts. */ - ret = conn_dev_sem_timedwait(&state.pr_sem, true, UINT_MAX, + ret = conn_dev_sem_timedwait(&state.pr_sem, true, + _SO_TIMEOUT(conn->sconn.s_rcvtimeo), &conn->sconn, dev); + if (ret == -ETIMEDOUT) + { + /* A frame can come after the timeout and before the wait + * gets the lock again. Keep that frame. + */ + + ret = state.pr_recvlen > 0 ? OK : -EAGAIN; + } /* Make sure that no further events are processed */
