This is an automated email from the ASF dual-hosted git repository. GUIDINGLI pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx-apps.git
commit 9d981050b5e7db3de96be9f97d708a5969487b42 Author: Marco Casaroli <[email protected]> AuthorDate: Wed Nov 25 19:31:38 2026 +0100 testing/nettest: Do not assume the TCP buffer size in the TIME_WAIT case. test_tcp_close_timewait sent 16 KiB with blocking send() before the server read anything. Since a connection by default may queue only 1/8 of the IOBs above the throttle in its write buffers and in its read-ahead, 16 KiB do not fit with small IOBs: with 96 IOBs of 196 bytes, send() takes 4312 bytes, then blocks until SO_SNDTIMEO and returns 216 ("216 != 512"). Fill the window of the server and the write queue of the client with tcp_close_fill(), as test_tcp_close_shutdown_queued does. The client then closes with data still queued, for every buffer size. Assisted-by: Claude Code:claude-opus-5-5 Signed-off-by: Marco Casaroli <[email protected]> --- testing/nettest/tcp/test_tcp_close.c | 25 ++++++------------------- 1 file changed, 6 insertions(+), 19 deletions(-) diff --git a/testing/nettest/tcp/test_tcp_close.c b/testing/nettest/tcp/test_tcp_close.c index f99d1c77b..9e48b72ae 100644 --- a/testing/nettest/tcp/test_tcp_close.c +++ b/testing/nettest/tcp/test_tcp_close.c @@ -67,7 +67,6 @@ #define TCP_CLOSE_SETTLE 3000 /* ms for a closed connection to go away */ #define TCP_CLOSE_ROUNDS 5 #define TCP_CLOSE_TWDATA 512 -#define TCP_CLOSE_LAST (16 * 1024) /* Enough connections in TIME_WAIT to hold all preallocated callbacks when * each one keeps three of them. @@ -622,9 +621,10 @@ void test_tcp_close_netdown(FAR void **state) * * Description: * Leave TCP_CLOSE_NTW connections in TIME_WAIT (the client closes - * first). Then a new client sends data and closes at once: the server - * must read every byte, then EOF. The connections in TIME_WAIT must not - * hold the callbacks that this close needs. + * first). Then a new client fills the window of the server and its own + * write queue, and closes at once: the server must read every byte, then + * EOF. The connections in TIME_WAIT must not hold the callbacks that + * this close needs. * ****************************************************************************/ @@ -633,9 +633,7 @@ void test_tcp_close_timewait(FAR void **state) FAR struct tcp_close_state_s *st = *state; struct tcp_close_pair_s pair; uint8_t buf[TCP_CLOSE_TWDATA]; - size_t sent = 0; - ssize_t n; - size_t i; + size_t sent; int conn; memset(buf, 't', sizeof(buf)); @@ -654,18 +652,7 @@ void test_tcp_close_timewait(FAR void **state) } tcp_close_pair(st, &pair); - while (sent < TCP_CLOSE_LAST) - { - for (i = 0; i < sizeof(buf); i++) - { - buf[i] = tcp_close_byte(sent + i); - } - - n = send(pair.client, buf, sizeof(buf), 0); - assert_int_equal(n, sizeof(buf)); - sent += n; - } - + sent = tcp_close_fill(pair.client); tcp_close_fd(st, pair.client); tcp_close_drain(pair.server, sent); tcp_close_fd(st, pair.server);
