From aa1ca95b8d62c99271a44e15b3eb2caaac6316e7 Mon Sep 17 00:00:00 2001 From: Richard McDaniel <1130888+rmcdaniel@users.noreply.github.com> Date: Tue, 3 Nov 2026 21:04:41 -0600 Subject: [PATCH] Read test fixture sockets as blocking on macOS On macOS and the BSDs an accepted socket inherits the listener's O_NONBLOCK, so the replay corpus, sticky proxy and lib mock worker servers read an empty request and answered 404. Set each accepted stream to blocking, with a write timeout so a client that stops reading cannot hang server shutdown. Test-only. Fixes #184 Co-Authored-By: Claude Opus 5.5 --- src/lib.rs | 3 +++ tests/replay_regression_corpus.rs | 3 +++ tests/sticky_server.rs | 5 +++++ 3 files changed, 11 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index 74b2a1dd..a67776a5 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -32672,6 +32672,9 @@ mod tests { while !server_stop.load(Ordering::SeqCst) { match listener.accept() { Ok((mut stream, _)) => { + // macOS/BSD accepted sockets inherit the listener's O_NONBLOCK. + let _ = stream.set_nonblocking(false); + let _ = stream.set_write_timeout(Some(Duration::from_secs(2))); if behavior.concurrent_requests { let requests = Arc::clone(&server_requests); request_threads.push(thread::spawn(move || { diff --git a/tests/replay_regression_corpus.rs b/tests/replay_regression_corpus.rs index 4e9417c7..ca922a5e 100644 --- a/tests/replay_regression_corpus.rs +++ b/tests/replay_regression_corpus.rs @@ -73,6 +73,9 @@ impl FixtureServer { while !server_stop.load(Ordering::SeqCst) { match listener.accept() { Ok((mut stream, _)) => { + // macOS/BSD accepted sockets inherit the listener's O_NONBLOCK. + let _ = stream.set_nonblocking(false); + let _ = stream.set_write_timeout(Some(Duration::from_secs(2))); handle_request( &mut stream, &server_requests, diff --git a/tests/sticky_server.rs b/tests/sticky_server.rs index 01f92d01..b4e16899 100644 --- a/tests/sticky_server.rs +++ b/tests/sticky_server.rs @@ -186,6 +186,11 @@ impl HistoryProxy { } Err(error) => panic!("proxy accept: {error}"), }; + // macOS/BSD accepted sockets inherit the listener's O_NONBLOCK. + incoming.set_nonblocking(false).unwrap(); + incoming + .set_write_timeout(Some(Duration::from_secs(10))) + .unwrap(); incoming .set_read_timeout(Some(Duration::from_secs(10))) .unwrap();