Make relay socket backpressure test hold on Linux

RawRelay stops reading while any forwarded write is incomplete. On Linux a
short socket read can stay below the 2 KiB high water mark, so the target
channel stays writable while the relay correctly waits. The test waited for
non-writability and timed out deterministically (writable=true,
pending=1632). Wait for a real pending socket write instead; the bounded
queue and exact byte-stream assertions are unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KcCN2hYyqmU22X2Xfg1nwe
This commit is contained in:
Claude committed 2026-10-05 20:11:18 +00:00
1 parent e300160500
commit 7086c4f38d
1 file changed
+4 -6
@@ -87,7 +87,7 @@ final class RawRelaySocketTest {
var sending = pair.workers.submit(() -> { writeFully(sender, payload); return null; });
long bytesWhenBlocked = awaitStableReads(observed, relayTarget,
"source reads stopped while the actual target socket was nonwritable");
"source reads stopped while the actual target socket had a pending write");
assertTrue(bytesWhenBlocked > before, "the source socket must deliver bytes before pressure");
assertTrue(bytesWhenBlocked < before + payload.length, "pressure must stop an unfinished transfer");
long pending = pendingBytes(relayTarget);
@@ -115,10 +115,6 @@ final class RawRelaySocketTest {
return bytes;
}
private static boolean isWritable(Channel channel) {
return channel.isWritable();
}
private static boolean isActive(Channel channel) {
return channel.isActive();
}
@@ -170,7 +166,9 @@ final class RawRelaySocketTest {
lastObserved = current;
stableSince = -1;
}
if (!isWritable(target) && current == lastObserved) {
// The relay stops reading while any forwarded write is incomplete. On Linux a short read can stay
// below the high water mark, so a real pending socket write is the condition, not writability.
if (pendingBytes(target) > 0 && current == lastObserved) {
if (stableSince < 0) stableSince = System.nanoTime();
if (System.nanoTime() - stableSince >= TimeUnit.MILLISECONDS.toNanos(250)) return current;
} else {