From 1fd4917191af9c5c011eabea72836fe4b41e7231 Mon Sep 17 00:00:00 2001 From: Helen Kwok <107752876+helenkwok@users.noreply.github.com> Date: Sat, 7 Nov 2026 13:07:24 +1030 Subject: [PATCH] tests: set TCP_NODELAY in the byte-timeout special reply The "Adapted byte timeout (7ms > 5ms)" check in unit-test-client relies on unit-test-server sending the reply one byte per send() with 5 ms between bytes. The server socket does not set TCP_NODELAY, so Nagle's algorithm may hold each byte until the previous one is acknowledged. On QNX 8.0 over IPv4 this pushes the gap past the 7 ms byte timeout and the check fails on every run (unit-test-client.c, "rc == 1"). Set TCP_NODELAY on the socket before sending the byte-by-byte reply so the test measures the library's byte timeout rather than the TCP stack's coalescing. Tested on QNX 8.0.0 (Raspberry Pi 4B, aarch64le, SDP 8.0 qcc): unit-tcp went from 0/10 to 10/10 passes; unit-tcppi, random-tcp and bandwidth-tcp still pass. Linux (Ubuntu 22.04, gcc): unit-test tcp and tcppi pass. --- tests/unit-test-server.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tests/unit-test-server.c b/tests/unit-test-server.c index b1e364837..49c1e2fd2 100644 --- a/tests/unit-test-server.c +++ b/tests/unit-test-server.c @@ -15,6 +15,8 @@ #ifdef _WIN32 # include #else +# include +# include # include #endif @@ -200,6 +202,19 @@ int main(int argc, char *argv[]) /* Copy TID */ req[1] = query[1]; + + /* Send each byte as soon as it is written. Without TCP_NODELAY, + * Nagle's algorithm may hold a byte until the previous one is + * acknowledged, so the gap between bytes can exceed the client's + * byte timeout (seen on QNX 8.0 over IPv4). */ + { + int option = 1; + setsockopt(w_s, + IPPROTO_TCP, + TCP_NODELAY, + (const char *) &option, + sizeof(option)); + } for (i = 0; i < req_length; i++) { printf("(%.2X)", req[i]); usleep(5000);