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

pkarashchenko pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git


The following commit(s) were added to refs/heads/master by this push:
     new fbe641a916 socket:return -EAGAIN if timeout happends in psock_tcp_send
fbe641a916 is described below

commit fbe641a9164ee04919f172a712f3845e47263d7d
Author: liangchaozhong <[email protected]>
AuthorDate: Thu Oct 27 16:45:30 2022 +0800

    socket:return -EAGAIN if timeout happends in psock_tcp_send
    
    psock_tcp_send will enter busyloop state when no IOB keeps at unavailable 
state
    when the socket is blocking socket and this will cause WDT.
    According to socket's manpage, -1 should be returned while errno set to 
EAGAIN
    if send/recv timeout was set.
    
    Here's the description:
    SO_RCVTIMEO and SO_SNDTIMEO
    Specify the receiving or sending timeouts until reporting an error. The 
argument is a struct timeval. If an input or output function blocks for this 
period of time, and data has been sent or received, the return value of that 
function will be the amount of data transferred; if no data has been 
transferred and the timeout has been reached then -1 is returned with errno set 
to EAGAIN or EWOULDBLOCK, or EINPROGRESS (for connect(2)) just as if the socket 
was specified to be nonblocking. I [...]
    
    Signed-off-by: liangchaozhong <[email protected]>
---
 net/tcp/tcp_send_buffered.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/net/tcp/tcp_send_buffered.c b/net/tcp/tcp_send_buffered.c
index 62651169c5..3c1d35016f 100644
--- a/net/tcp/tcp_send_buffered.c
+++ b/net/tcp/tcp_send_buffered.c
@@ -1549,6 +1549,12 @@ ssize_t psock_tcp_send(FAR struct socket *psock, FAR 
const void *buf,
             {
               iob_free_chain(iob);
             }
+          else
+            {
+              nerr("ERROR: no IOB available\n");
+              ret = -EAGAIN;
+              goto errout_with_lock;
+            }
         }
 
       /* Dump I/O buffer chain */

Reply via email to