From 1c4e265a708b7ed600d96c8e03f3ac0e5b801502 Mon Sep 17 00:00:00 2001 From: "Bryan A. Jones" <2125584+bjones1@users.noreply.github.com> Date: Tue, 1 Oct 2024 02:08:34 -0500 Subject: [PATCH] Set `SO_REUSEADDR` only non-Windows platforms (#3473) * Fix: Per discussion in #2958, set `SO_REUSEADDR` only non-Windows platforms. Add: Tests confirming that only a single webserver instance may bind to a given address. * Clean: Lint. * Clean: another guess at making the formatter happy. * Clean: More cargo fmt fun. (Running cargo fmt locally doesn't help.) --------- Co-authored-by: Bryan A. Jones Co-authored-by: Rob Ede --- actix-web/CHANGES.md | 1 + actix-web/src/server.rs | 5 ++++- actix-web/tests/test_httpserver.rs | 30 ++++++++++++++++++++++++------ 3 files changed, 29 insertions(+), 7 deletions(-) diff --git a/actix-web/CHANGES.md b/actix-web/CHANGES.md index 36e8b62dd..aca4ccfae 100644 --- a/actix-web/CHANGES.md +++ b/actix-web/CHANGES.md @@ -3,6 +3,7 @@ ## Unreleased - Minimum supported Rust version (MSRV) is now 1.75. +- On Windows platforms, produce an error when invoking `HttpServer::bind` on a socket that's already in use. See [issue 2958](https://github.com/actix/actix-web/issues/2958). ## 4.9.0 diff --git a/actix-web/src/server.rs b/actix-web/src/server.rs index d8519fb9e..4fbeb0186 100644 --- a/actix-web/src/server.rs +++ b/actix-web/src/server.rs @@ -1085,7 +1085,10 @@ fn create_tcp_listener(addr: net::SocketAddr, backlog: u32) -> io::Result