From c5a8420089de30cc222786efae09db9423e44967 Mon Sep 17 00:00:00 2001 From: Hamza Date: Fri, 16 Oct 2026 16:27:05 +0500 Subject: [PATCH] Make the control server's connection-limit test pass on macOS `cargo xtask ci` was red on a clean main on macOS: the test's last shutdown runs after the server has answered an invalid request and closed the connection, and `shutdown(2)` on a socket whose peer has already closed is ENOTCONN on macOS and the BSDs where Linux returns success. The test is right about what it checks; it checked a return value that is not portable. Closing the client is what the worker thread waits for, and dropping the socket does that whether or not shutdown reported anything. The file's other six shutdowns run while the peer is still open, which is well defined on both platforms, so they stay checked. With no CI running the tests on pull requests, the local gate is the only signal a contributor gets, and it could not be green on macOS. --- apps/figcraft/src/control_server_tests.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/apps/figcraft/src/control_server_tests.rs b/apps/figcraft/src/control_server_tests.rs index d243fb91..008170fb 100644 --- a/apps/figcraft/src/control_server_tests.rs +++ b/apps/figcraft/src/control_server_tests.rs @@ -160,7 +160,11 @@ fn connection_limit_rejects_excess_clients_and_reuses_finished_slots() { assert_eq!(workers.len(), 1); client.write_all(b"invalid\n").unwrap(); assert_eq!(reply(&mut BufReader::new(client.try_clone().unwrap()))["ok"], false); - client.shutdown(Shutdown::Both).unwrap(); + // The server closes this connection after answering an invalid request, and shutting down + // a socket whose peer has already closed is ENOTCONN on macOS and the BSDs where Linux + // returns Ok. Closing the client is what the worker is waiting for, so the result is moot: + // the other shutdowns in this file run while the peer is still open and stay checked. + let _ = client.shutdown(Shutdown::Both); workers.pop().unwrap().join().unwrap(); }