Merge pull request #1470 from lightpanda-io/fix_bsd_test_server_shutdown

use close, not shutdown on BSD/Mac
This commit is contained in:
Karl Seguin
2026-02-05 11:25:37 +08:00
committed by GitHub

View File

@@ -41,9 +41,10 @@ pub fn deinit(self: *TestHTTPServer) void {
pub fn stop(self: *TestHTTPServer) void {
self.shutdown.store(true, .release);
if (self.listener) |*listener| {
// Use shutdown to unblock accept(). On Linux this causes accept to
// return error.SocketNotListening. close() alone doesn't interrupt accept().
std.posix.shutdown(listener.stream.handle, .recv) catch {};
switch (@import("builtin").target.os.tag) {
.linux => std.posix.shutdown(listener.stream.handle, .recv) catch {},
else => std.posix.close(listener.stream.handle),
}
}
}