Skip to content
Merged
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
5 changes: 0 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,6 @@ webpki-roots = ["dep:webpki-root-certs"]
# Use the system's proxy configuration.
system-proxy = ["dep:system-configuration", "dep:windows-registry"]

# Deprecated, switch to system-proxy.
macos-system-configuration = ["system-proxy"]

# Optional enable tracing
tracing = ["http2/tracing", "dep:tracing"]

Expand Down Expand Up @@ -163,12 +160,10 @@ hyper-util = { version = "0.1.13", features = [
"server-graceful",
"tokio",
] }
log = "0.4"
serde = { version = "1.0", features = ["derive"] }
flate2 = "1.1.1"
zstd = "0.13"
brotli = "8.0.0"
doc-comment = "0.3"
tokio = { version = "1.0", default-features = false, features = [
"macros",
"rt-multi-thread",
Expand Down
9 changes: 6 additions & 3 deletions examples/connect_via_lower_priority_tokio_runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@

#[tokio::main]
async fn main() -> wreq::Result<()> {
tracing_subscriber::fmt()
.with_max_level(tracing::Level::TRACE)
.init();
background_threadpool::init_background_runtime();
tokio::time::sleep(std::time::Duration::from_millis(10)).await;

Expand Down Expand Up @@ -83,7 +86,7 @@ mod background_threadpool {
*libc::__errno_location() = 0;
if libc::nice(10) == -1 && *libc::__errno_location() != 0 {
let error = std::io::Error::last_os_error();
log::error!("failed to set threadpool niceness: {error}");
tracing::error!("failed to set threadpool niceness: {error}");
}
}
}
Expand All @@ -92,7 +95,7 @@ mod background_threadpool {
.build()
.unwrap_or_else(|e| panic!("cpu heavy runtime failed_to_initialize: {e}"));
rt.block_on(async {
log::debug!("starting background cpu-heavy work");
tracing::debug!("starting background cpu-heavy work");
process_cpu_work().await;
});
})
Expand Down Expand Up @@ -122,7 +125,7 @@ mod background_threadpool {
panic!("background cpu heavy runtime channel is closed")
}
Err(TrySendError::Full(msg)) => {
log::warn!(
tracing::warn!(
"background cpu heavy runtime channel is full, task spawning loop delayed"
);
let tx = tx.clone();
Expand Down
233 changes: 0 additions & 233 deletions src/core/client/conn/http2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -254,236 +254,3 @@ where
}
}
}

#[cfg(test)]
mod tests {
use http_body::Body;

use super::{Builder, Connection, SendRequest};
use crate::core::{
error::BoxError,
rt::{Read, Write, bounds::Http2ClientConnExec},
};

pub async fn handshake<E, T, B>(
exec: E,
io: T,
) -> crate::core::Result<(SendRequest<B>, Connection<T, B, E>)>
where
T: Read + Write + Unpin,
B: Body + 'static,
B::Data: Send,
B::Error: Into<BoxError>,
E: Http2ClientConnExec<B, T> + Unpin + Clone,
{
Builder::new(exec).handshake(io).await
}

#[tokio::test]
#[ignore] // only compilation is checked
async fn send_sync_executor_of_non_send_futures() {
#[derive(Clone)]
struct LocalTokioExecutor;

impl<F> crate::core::rt::Executor<F> for LocalTokioExecutor
where
F: std::future::Future + 'static, // not requiring `Send`
{
fn execute(&self, fut: F) {
// This will spawn into the currently running `LocalSet`.
tokio::task::spawn_local(fut);
}
}

#[allow(unused)]
async fn run(io: impl crate::core::rt::Read + crate::core::rt::Write + Unpin + 'static) {
let (_sender, conn) =
handshake::<_, _, http_body_util::Empty<bytes::Bytes>>(LocalTokioExecutor, io)
.await
.unwrap();

tokio::task::spawn_local(async move {
conn.await.unwrap();
});
}
}

#[tokio::test]
#[ignore] // only compilation is checked
async fn not_send_not_sync_executor_of_not_send_futures() {
#[derive(Clone)]
struct LocalTokioExecutor {
_x: std::marker::PhantomData<std::rc::Rc<()>>,
}

impl<F> crate::core::rt::Executor<F> for LocalTokioExecutor
where
F: std::future::Future + 'static, // not requiring `Send`
{
fn execute(&self, fut: F) {
// This will spawn into the currently running `LocalSet`.
tokio::task::spawn_local(fut);
}
}

#[allow(unused)]
async fn run(io: impl crate::core::rt::Read + crate::core::rt::Write + Unpin + 'static) {
let (_sender, conn) = handshake::<_, _, http_body_util::Empty<bytes::Bytes>>(
LocalTokioExecutor {
_x: Default::default(),
},
io,
)
.await
.unwrap();

tokio::task::spawn_local(async move {
conn.await.unwrap();
});
}
}

#[tokio::test]
#[ignore] // only compilation is checked
async fn send_not_sync_executor_of_not_send_futures() {
#[derive(Clone)]
struct LocalTokioExecutor {
_x: std::marker::PhantomData<std::cell::Cell<()>>,
}

impl<F> crate::core::rt::Executor<F> for LocalTokioExecutor
where
F: std::future::Future + 'static, // not requiring `Send`
{
fn execute(&self, fut: F) {
// This will spawn into the currently running `LocalSet`.
tokio::task::spawn_local(fut);
}
}

#[allow(unused)]
async fn run(io: impl crate::core::rt::Read + crate::core::rt::Write + Unpin + 'static) {
let (_sender, conn) = handshake::<_, _, http_body_util::Empty<bytes::Bytes>>(
LocalTokioExecutor {
_x: Default::default(),
},
io,
)
.await
.unwrap();

tokio::task::spawn_local(async move {
conn.await.unwrap();
});
}
}

#[tokio::test]
#[ignore] // only compilation is checked
async fn send_sync_executor_of_send_futures() {
#[derive(Clone)]
struct TokioExecutor;

impl<F> crate::core::rt::Executor<F> for TokioExecutor
where
F: std::future::Future + 'static + Send,
F::Output: Send + 'static,
{
fn execute(&self, fut: F) {
tokio::task::spawn(fut);
}
}

#[allow(unused)]
async fn run(
io: impl crate::core::rt::Read + crate::core::rt::Write + Send + Unpin + 'static,
) {
let (_sender, conn) =
handshake::<_, _, http_body_util::Empty<bytes::Bytes>>(TokioExecutor, io)
.await
.unwrap();

tokio::task::spawn(async move {
conn.await.unwrap();
});
}
}

#[tokio::test]
#[ignore] // only compilation is checked
async fn not_send_not_sync_executor_of_send_futures() {
#[derive(Clone)]
struct TokioExecutor {
// !Send, !Sync
_x: std::marker::PhantomData<std::rc::Rc<()>>,
}

impl<F> crate::core::rt::Executor<F> for TokioExecutor
where
F: std::future::Future + 'static + Send,
F::Output: Send + 'static,
{
fn execute(&self, fut: F) {
tokio::task::spawn(fut);
}
}

#[allow(unused)]
async fn run(
io: impl crate::core::rt::Read + crate::core::rt::Write + Send + Unpin + 'static,
) {
let (_sender, conn) = handshake::<_, _, http_body_util::Empty<bytes::Bytes>>(
TokioExecutor {
_x: Default::default(),
},
io,
)
.await
.unwrap();

tokio::task::spawn_local(async move {
// can't use spawn here because when executor is !Send
conn.await.unwrap();
});
}
}

#[tokio::test]
#[ignore] // only compilation is checked
async fn send_not_sync_executor_of_send_futures() {
#[derive(Clone)]
struct TokioExecutor {
// !Sync
_x: std::marker::PhantomData<std::cell::Cell<()>>,
}

impl<F> crate::core::rt::Executor<F> for TokioExecutor
where
F: std::future::Future + 'static + Send,
F::Output: Send + 'static,
{
fn execute(&self, fut: F) {
tokio::task::spawn(fut);
}
}

#[allow(unused)]
async fn run(
io: impl crate::core::rt::Read + crate::core::rt::Write + Send + Unpin + 'static,
) {
let (_sender, conn) = handshake::<_, _, http_body_util::Empty<bytes::Bytes>>(
TokioExecutor {
_x: Default::default(),
},
io,
)
.await
.unwrap();

tokio::task::spawn_local(async move {
// can't use spawn here because when executor is !Send
conn.await.unwrap();
});
}
}
}
34 changes: 0 additions & 34 deletions src/core/proto/h1/io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -625,40 +625,6 @@ mod tests {
use super::*;
use crate::core::common::io::Compat;

// #[cfg(feature = "nightly")]
// use test::Bencher;

/*
impl<T: Read> MemRead for AsyncIo<T> {
fn read_mem(&mut self, len: usize) -> Poll<Bytes, io::Error> {
let mut v = vec![0; len];
let n = try_nb!(self.read(v.as_mut_slice()));
Ok(Async::Ready(BytesMut::from(&v[..n]).freeze()))
}
}
*/

#[tokio::test]
#[ignore]
async fn iobuf_write_empty_slice() {
// TODO(eliza): can i have writev back pls T_T
// // First, let's just check that the Mock would normally return an
// // error on an unexpected write, even if the buffer is empty...
// let mut mock = Mock::new().build();
// std::future::poll_fn(|cx| {
// Pin::new(&mut mock).poll_write_buf(cx, &mut Cursor::new(&[]))
// })
// .await
// .expect_err("should be a broken pipe");

// // underlying io will return the logic error upon write,
// // so we are testing that the io_buf does not trigger a write
// // when there is nothing to flush
// let mock = Mock::new().build();
// let mut io_buf = Buffered::<_, Cursor<Vec<u8>>>::new(mock);
// io_buf.flush().await.expect("should short-circuit flush");
}

#[cfg(not(miri))]
#[tokio::test]
async fn parse_reads_until_blocked() {
Expand Down
3 changes: 0 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -316,9 +316,6 @@ fn _assert_impls() {
assert_sync::<Error>();
}

#[cfg(test)]
doc_comment::doctest!("../README.md");

#[cfg(feature = "multipart")]
pub use self::client::multipart;
#[cfg(feature = "websocket")]
Expand Down
Loading