net/tcp: fix potential busy loop in tcp_send_buffered.c

if the wrbuffer does not have enough space to send the rest of
the data, then the send function will loop infinitely in nonblock
mode, add send timeout check to avoid this issue.

Signed-off-by: chao an <anchao@xiaomi.com>
This commit is contained in:
chao an 2023-01-16 12:37:44 +08:00 committed by Xiang Xiao
parent 1b333bfad5
commit 715785245c
1 changed files with 2 additions and 1 deletions

View File

@ -1361,7 +1361,8 @@ ssize_t psock_tcp_send(FAR struct socket *psock, FAR const void *buf,
tcp_wrbuffer_release(wrb);
}
if (nonblock)
if (nonblock || (timeout != UINT_MAX &&
tcp_send_gettimeout(start, timeout) == 0))
{
nerr("ERROR: Failed to add data to the I/O chain\n");
ret = -EAGAIN;