From 27d2405b652d00a7bbbd0b3ff9c97c680e76eb17 Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Sun, 3 Jan 2021 22:49:59 +0000 Subject: [PATCH] HttpServer::backlog takes a u32 --- CHANGES.md | 6 ++++-- actix-files/CHANGES.md | 4 +++- actix-files/Cargo.toml | 2 +- actix-http-test/CHANGES.md | 4 +++- actix-http/CHANGES.md | 9 ++++++--- actix-multipart/CHANGES.md | 4 +++- actix-web-actors/CHANGES.md | 5 +++-- awc/CHANGES.md | 8 +++++--- awc/src/ws.rs | 1 + src/server.rs | 10 ++++++---- 10 files changed, 35 insertions(+), 18 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index a0503c86d..4cba158ef 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -2,11 +2,13 @@ ## Unreleased - 2021-xx-xx ### Changed -* Bumped `rand` to `0.8` -* Update `rust-tls` to `0.19.0` +* Bumped `rand` to `0.8`. +* Update `rust-tls` to `0.19`. [#1813] * Rename `Handler` to `HandlerService` and rename `Factory` to `Handler`. [#1852] * MSRV is now 1.46.0. +[#1813]: https://github.com/actix/actix-web/pull/1813 + ### Fixed * added the actual parsing error to `test::read_body_json` [#1812] diff --git a/actix-files/CHANGES.md b/actix-files/CHANGES.md index eb5ca79df..6dcf4f66f 100644 --- a/actix-files/CHANGES.md +++ b/actix-files/CHANGES.md @@ -2,7 +2,9 @@ ## Unreleased - 2021-xx-xx * `HttpRange::parse` now has its own error type. -* Update `bytes` to `1`. +* Update `bytes` to `1.0`. [#1813] + +[#1813]: https://github.com/actix/actix-web/pull/1813 ## 0.5.0 - 2020-12-26 diff --git a/actix-files/Cargo.toml b/actix-files/Cargo.toml index 1b47a8cc6..17e1a4888 100644 --- a/actix-files/Cargo.toml +++ b/actix-files/Cargo.toml @@ -22,7 +22,7 @@ actix-service = "2.0.0-beta.2" bitflags = "1" bytes = "1" futures-core = { version = "0.3.7", default-features = false } -futures-util = { version = "0.3.7", default-features = false, features = ["sink"] } +futures-util = { version = "0.3.7", default-features = false } derive_more = "0.99.5" log = "0.4" mime = "0.3" diff --git a/actix-http-test/CHANGES.md b/actix-http-test/CHANGES.md index 5e4f5a7a5..6ed6a0603 100644 --- a/actix-http-test/CHANGES.md +++ b/actix-http-test/CHANGES.md @@ -1,7 +1,9 @@ # Changes ## Unreleased - 2021-xx-xx -* Update `bytes` to `1`. +* Update `bytes` to `1.0`. [#1813] + +[#1813]: https://github.com/actix/actix-web/pull/1813 ## 2.1.0 - 2020-11-25 diff --git a/actix-http/CHANGES.md b/actix-http/CHANGES.md index e08aef5e5..a4caa0c59 100644 --- a/actix-http/CHANGES.md +++ b/actix-http/CHANGES.md @@ -2,9 +2,12 @@ ## Unreleased - 2021-xx-xx ### Changed -* Bumped `rand` to `0.8` -* Upgrade `bytes` to `1` -* Upgrade `h2` to `0.3` +* Bumped `rand` to `0.8`. +* Update `bytes` to `1.0`. [#1813] +* Update `h2` to `0.3`. [#1813] + +[#1813]: https://github.com/actix/actix-web/pull/1813 + ### Removed * Deprecated `on_connect` methods have been removed. Prefer the new diff --git a/actix-multipart/CHANGES.md b/actix-multipart/CHANGES.md index a8216c4f5..4c6f01d29 100644 --- a/actix-multipart/CHANGES.md +++ b/actix-multipart/CHANGES.md @@ -2,7 +2,9 @@ ## Unreleased - 2021-xx-xx * Fix multipart consuming payload before header checks #1513 -* Update `bytes` to `1` +* Update `bytes` to `1.0`. [#1813] + +[#1813]: https://github.com/actix/actix-web/pull/1813 ## 3.0.0 - 2020-09-11 diff --git a/actix-web-actors/CHANGES.md b/actix-web-actors/CHANGES.md index dfda1c6e4..e47f09135 100644 --- a/actix-web-actors/CHANGES.md +++ b/actix-web-actors/CHANGES.md @@ -1,9 +1,10 @@ # Changes ## Unreleased - 2021-xx-xx -* Upgrade `pin-project` to `1.0`. -* Update `bytes` to `1`. +* Update `pin-project` to `1.0`. +* Update `bytes` to `1.0`. [#1813] +[#1813]: https://github.com/actix/actix-web/pull/1813 ## 3.0.0 - 2020-09-11 * No significant changes from `3.0.0-beta.2`. diff --git a/awc/CHANGES.md b/awc/CHANGES.md index 3bfdb6021..45a38259c 100644 --- a/awc/CHANGES.md +++ b/awc/CHANGES.md @@ -2,9 +2,11 @@ ## Unreleased - 2021-xx-xx ### Changed -* Upgrade `bytes` to `1`. -* Bumped `rand` to `0.8` -* Update `rust-tls` to `0.19.0` +* Update `rand` to `0.8` +* Update `bytes` to `1.0`. [#1813] +* Update `rust-tls` to `0.19`. [#1813] + +[#1813]: https://github.com/actix/actix-web/pull/1813 ## 2.0.3 - 2020-11-29 diff --git a/awc/src/ws.rs b/awc/src/ws.rs index eaa681344..dd43d08b3 100644 --- a/awc/src/ws.rs +++ b/awc/src/ws.rs @@ -71,6 +71,7 @@ impl WebsocketsRequest { { let mut err = None; + #[allow(clippy::field_reassign_with_default)] let mut head = { let mut head = RequestHead::default(); head.method = Method::GET; diff --git a/src/server.rs b/src/server.rs index 29334eabc..fc80cbed8 100644 --- a/src/server.rs +++ b/src/server.rs @@ -67,7 +67,7 @@ where { pub(super) factory: F, config: Arc>, - backlog: i32, + backlog: u32, sockets: Vec, builder: ServerBuilder, on_connect_fn: Option>, @@ -148,9 +148,9 @@ where /// Generally set in the 64-2048 range. Default value is 2048. /// /// This method should be called before `bind()` method call. - pub fn backlog(mut self, backlog: i32) -> Self { + pub fn backlog(mut self, backlog: u32) -> Self { self.backlog = backlog; - self.builder = self.builder.backlog(backlog as u32); + self.builder = self.builder.backlog(backlog); self } @@ -642,7 +642,7 @@ where fn create_tcp_listener( addr: net::SocketAddr, - backlog: i32, + backlog: u32, ) -> io::Result { use socket2::{Domain, Protocol, Socket, Type}; let domain = match addr { @@ -652,6 +652,8 @@ fn create_tcp_listener( let socket = Socket::new(domain, Type::stream(), Some(Protocol::tcp()))?; socket.set_reuse_address(true)?; socket.bind(&addr.into())?; + // clamp backlog to max u32 that fits in i32 range + let backlog = backlog.min(i32::MAX as u32) as i32; socket.listen(backlog)?; Ok(socket.into_tcp_listener()) }