diff --git a/Cargo.toml b/Cargo.toml index ac1141b3ee..df194c90ec 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -29,7 +29,7 @@ http-body = "0.3.1" httpdate = "0.3" httparse = "1.0" h2 = "0.2.2" -itoa = "0.4.1" +itoa = "1" tracing = { version = "0.1", default-features = false, features = ["log", "std"] } pin-project = "1.0" tower-service = "0.3" @@ -56,7 +56,7 @@ tower-util = "0.3" url = "1.0" [target.'cfg(any(target_os = "linux", target_os = "macos"))'.dev-dependencies] -pnet = "0.25.0" +pnet = "0.29.0" [features] default = [ diff --git a/src/common/drain.rs b/src/common/drain.rs index 7abb9f9ded..97c976fdd3 100644 --- a/src/common/drain.rs +++ b/src/common/drain.rs @@ -35,6 +35,8 @@ pub struct Draining { } #[derive(Clone)] +// drained_tx is never ready +#[allow(dead_code)] pub struct Watch { drained_tx: mpsc::Sender, rx: watch::Receiver, diff --git a/src/common/sync_wrapper.rs b/src/common/sync_wrapper.rs index 1e4aa4039c..aac9d4ee74 100644 --- a/src/common/sync_wrapper.rs +++ b/src/common/sync_wrapper.rs @@ -1,11 +1,6 @@ /* * This is a copy of the sync_wrapper crate. */ -//! A mutual exclusion primitive that relies on static type information only -//! -//! This library is inspired by [this discussion](https://internals.rust-lang.org/t/what-shall-sync-mean-across-an-await/12020/2). -#![doc(html_logo_url = "https://developer.actyx.com/img/logo.svg")] -#![doc(html_favicon_url = "https://developer.actyx.com/img/favicon.ico")] /// A mutual exclusion primitive that relies on static type information only /// diff --git a/src/proto/h1/role.rs b/src/proto/h1/role.rs index ca8e52c30d..9c8759d28e 100644 --- a/src/proto/h1/role.rs +++ b/src/proto/h1/role.rs @@ -111,13 +111,9 @@ impl Http1Transaction for Server { let len; let headers_len; - // Unsafe: both headers_indices and headers are using uninitialized memory, - // but we *never* read any of it until after httparse has assigned - // values into it. By not zeroing out the stack memory, this saves - // a good ~5% on pipeline benchmarks. - let mut headers_indices: [HeaderIndices; MAX_HEADERS] = unsafe { mem::uninitialized() }; + let mut headers_indices: [HeaderIndices; MAX_HEADERS] = unsafe { mem::zeroed() }; { - let mut headers: [httparse::Header<'_>; MAX_HEADERS] = unsafe { mem::uninitialized() }; + let mut headers = [httparse::EMPTY_HEADER; MAX_HEADERS]; trace!( "Request.parse([Header; {}], [u8; {}])", headers.len(), @@ -276,7 +272,7 @@ impl Http1Transaction for Server { fn encode( mut msg: Encode<'_, Self::Outgoing>, - mut dst: &mut Vec, + dst: &mut Vec, ) -> crate::Result { trace!( "Server::encode status={:?}, body={:?}, req_method={:?}", @@ -562,7 +558,8 @@ impl Http1Transaction for Server { Encoder::length(0) } else { extend(dst, b"content-length: "); - let _ = ::itoa::write(&mut dst, len); + let mut buf = itoa::Buffer::new(); + extend(dst, buf.format(len).as_bytes()); extend(dst, b"\r\n"); Encoder::length(len) } @@ -650,11 +647,9 @@ impl Http1Transaction for Client { // Loop to skip information status code headers (100 Continue, etc). loop { - // Unsafe: see comment in Server Http1Transaction, above. - let mut headers_indices: [HeaderIndices; MAX_HEADERS] = unsafe { mem::uninitialized() }; + let mut headers_indices: [HeaderIndices; MAX_HEADERS] = unsafe { mem::zeroed() }; let (len, status, version, headers_len) = { - let mut headers: [httparse::Header<'_>; MAX_HEADERS] = - unsafe { mem::uninitialized() }; + let mut headers = [httparse::EMPTY_HEADER; MAX_HEADERS]; trace!( "Response.parse([Header; {}], [u8; {}])", headers.len(),