The :grow, :truncate and :eagain_vs_eof cases rely on the socket
buffers filling up before the whole file has been sent. :grow and
:truncate shrank SO_SNDBUF and SO_RCVBUF only after the connection was
established, when the receiver had already advertised a window based on
the default buffer size; TCP does not shrink an advertised window.
:eagain_vs_eof used the default, autosized buffers. With a large
net.inet.tcp.recvspace, or once autosizing has grown the buffers, the
whole 2 MB file fits in the socket buffers:
- :grow and :truncate: sendfile(2) returns before the file is resized, and the poll loop that waits for the sender to block spins forever on a writable socket.
- :eagain_vs_eof: the loop that keeps writing until EAGAIN never sees it, since sendfile(2) returns 0 at EOF.
Either way kyua reports a timeout, which is why doubling the timeouts
did not help. Apply a 128 KB buffer size to the listening socket, which
the accepted socket inherits, and to the client socket before
connect(2) in all three cases, and revert the timeout increase.
Under CPU load in a test VM, :eagain_vs_eof timed out in 3 of 11 runs
without this change and passed 40 of 40 runs with it. With 1 MB
recvspace and sendspace, :grow hung on its first run in 3 of 4 boots
without it and passed 20 of 20 runs with it.