HttpServer::backlog takes a u32

This commit is contained in:
Rob Ede 2021-01-03 22:49:59 +00:00
parent f38db886cf
commit 27d2405b65
No known key found for this signature in database
GPG Key ID: C2A3B36E841A91E6
10 changed files with 35 additions and 18 deletions

View File

@ -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]

View File

@ -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

View File

@ -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"

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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`.

View File

@ -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

View File

@ -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;

View File

@ -67,7 +67,7 @@ where
{
pub(super) factory: F,
config: Arc<Mutex<Config>>,
backlog: i32,
backlog: u32,
sockets: Vec<Socket>,
builder: ServerBuilder,
on_connect_fn: Option<Arc<dyn Fn(&dyn Any, &mut Extensions) + Send + Sync>>,
@ -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<net::TcpListener> {
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())
}