net/udp: Let cansend return EWOULDBLOCK when send buffer is full

Notes:
1. This commit do the same thing as TCP did: https://github.com/apache/nuttx/pull/10627
2. UDP uses `iob_navail(false)` but TCP uses `iob_navail(true)`, this is because of a problem related to TCP recv window (https://github.com/apache/nuttx/pull/4142), so we don't need to change UDP now.

Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
This commit is contained in:
Zhe Weng 2025-01-02 14:17:45 +08:00 committed by Xiang Xiao
parent 6fb12b0284
commit 3b26c6df51

View file

@ -941,7 +941,11 @@ int psock_udp_cansend(FAR struct udp_conn_s *conn)
* many more. * many more.
*/ */
if (udp_wrbuffer_test() < 0 || iob_navail(false) <= 0) if (udp_wrbuffer_test() < 0 || iob_navail(false) <= 0
#if CONFIG_NET_SEND_BUFSIZE > 0
|| udp_wrbuffer_inqueue_size(conn) >= conn->sndbufs
#endif
)
{ {
return -EWOULDBLOCK; return -EWOULDBLOCK;
} }