Skip to content

tests: set TCP_NODELAY in the byte-timeout special reply - #892

Open
helenkwok wants to merge 1 commit into
stephane:masterfrom
helenkwok:tests-tcp-nodelay
Open

helenkwok wants to merge 1 commit into
stephane:masterfrom
helenkwok:tests-tcp-nodelay

Conversation

@helenkwok

Copy link
Copy Markdown

The "Adapted byte timeout (7ms > 5ms)" check in unit-test-client relies on unit-test-server sending the reply one byte per send(), 5 ms apart. The server socket doesn't set TCP_NODELAY, so Nagle's algorithm can 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). The same suite over IPv6 (tcppi) passes.

This sets TCP_NODELAY on the socket before the byte-by-byte reply, so the test measures libmodbus's byte timeout rather than the TCP stack's coalescing. Only the test server changes; the library is untouched.

Tested

  • QNX 8.0.0, Raspberry Pi 4B (aarch64le), built with the SDP 8.0 qcc (gcc 12.2.0): unit-test tcp went from 0/10 to 10/10 passes; tcppi, random-test and bandwidth tests still pass.
  • Linux (Ubuntu 22.04, gcc 11): ./configure && make with no warnings; unit-test tcp and tcppi pass.
  • The patched file is clean with clang-format and -Wall -Wextra -Werror.

Not tested on Windows. TCP_NODELAY and IPPROTO_TCP come from winsock2.h there, which the file already includes.

I agree to the terms of the Contributor License Agreement (CLA.txt).

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.
@cla-bot

cla-bot Bot commented Nov 7, 2026

Copy link
Copy Markdown

We require contributors to sign our Contributor License Agreement. In order for us to review and merge your code, please fill https://forms.gle/5635zjphDo5JEJQSA to get added. Your document will be manually checked by the maintainer. Be patient...

@helenkwok

Copy link
Copy Markdown
Author

@cla-bot check

@cla-bot

cla-bot Bot commented Nov 9, 2026

Copy link
Copy Markdown

We require contributors to sign our Contributor License Agreement. In order for us to review and merge your code, please fill https://forms.gle/5635zjphDo5JEJQSA to get added. Your document will be manually checked by the maintainer. Be patient...

@cla-bot

cla-bot Bot commented Nov 9, 2026

Copy link
Copy Markdown

The cla-bot has been summoned, and re-checked this pull request!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant