This is an automated email from the ASF dual-hosted git repository.

simbit18 pushed a commit to branch releases/13.1
in repository https://gitbox.apache.org/repos/asf/nuttx.git


The following commit(s) were added to refs/heads/releases/13.1 by this push:
     new 05518670c53 net/can: Honor SO_RCVTIMEO in can_recvmsg().
05518670c53 is described below

commit 05518670c53e643e4c23098c01675be5765c1943
Author: raiden00pl <[email protected]>
AuthorDate: Sat Oct 10 15:40:06 2026 +0200

    net/can: Honor SO_RCVTIMEO in can_recvmsg().
    
    can_recvmsg() waited for a frame with an UINT_MAX timeout, so a
    blocking read on an idle CAN socket never returned even with
    SO_RCVTIMEO set.  Wait for _SO_TIMEOUT(s_rcvtimeo) instead and return
    EAGAIN on timeout, as udp_recvfrom() does.
    
    Assisted-by: Claude:claude-opus-5-5
    Signed-off-by: raiden00pl <[email protected]>
---
 net/can/can_recvmsg.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/net/can/can_recvmsg.c b/net/can/can_recvmsg.c
index d69fbbc52d9..4c04a749eae 100644
--- a/net/can/can_recvmsg.c
+++ b/net/can/can_recvmsg.c
@@ -514,8 +514,13 @@ ssize_t can_recvmsg(FAR struct socket *psock, FAR struct 
msghdr *msg,
        * 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)
+        {
+          ret = -EAGAIN;
+        }
 
       /* Make sure that no further events are processed */
 

Reply via email to