Skip to content

Bump itoa version, don't use mem::uninit (0.13 backport) #2915

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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 = [
Expand Down
2 changes: 2 additions & 0 deletions src/common/drain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ pub struct Draining {
}

#[derive(Clone)]
// drained_tx is never ready
#[allow(dead_code)]
pub struct Watch {
drained_tx: mpsc::Sender<Never>,
rx: watch::Receiver<Action>,
Expand Down
5 changes: 0 additions & 5 deletions src/common/sync_wrapper.rs
Original file line number Diff line number Diff line change
@@ -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
///
Expand Down
19 changes: 7 additions & 12 deletions src/proto/h1/role.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down Expand Up @@ -276,7 +272,7 @@ impl Http1Transaction for Server {

fn encode(
mut msg: Encode<'_, Self::Outgoing>,
mut dst: &mut Vec<u8>,
dst: &mut Vec<u8>,
) -> crate::Result<Encoder> {
trace!(
"Server::encode status={:?}, body={:?}, req_method={:?}",
Expand Down Expand Up @@ -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)
}
Expand Down Expand Up @@ -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(),
Expand Down