diff --git a/examples/single_threaded.rs b/examples/single_threaded.rs index e8885cdb78..ba3e449ceb 100644 --- a/examples/single_threaded.rs +++ b/examples/single_threaded.rs @@ -2,6 +2,7 @@ use std::cell::Cell; use std::rc::Rc; +use tokio::sync::oneshot; use hyper::body::{Bytes, HttpBody}; use hyper::header::{HeaderMap, HeaderValue}; @@ -81,6 +82,13 @@ async fn run() { let server = Server::bind(&addr).executor(LocalExec).serve(make_service); + // Just shows that with_graceful_shutdown compiles with !Send, + // !Sync HttpBody. + let (_tx, rx) = oneshot::channel::<()>(); + let server = server.with_graceful_shutdown(async move { + rx.await.ok(); + }); + println!("Listening on http://{}", addr); // The server would block on current thread to await !Send futures. diff --git a/src/server/server.rs b/src/server/server.rs index 377f7cb617..0d559c579d 100644 --- a/src/server/server.rs +++ b/src/server/server.rs @@ -121,7 +121,7 @@ where IO: AsyncRead + AsyncWrite + Unpin + Send + 'static, S: MakeServiceRef, S::Error: Into>, - B: HttpBody + Send + Sync + 'static, + B: HttpBody + 'static, B::Error: Into>, E: ConnStreamExec<>::Future, B>, E: NewSvcExec, diff --git a/src/server/shutdown.rs b/src/server/shutdown.rs index 8a2ecaf306..2277a40964 100644 --- a/src/server/shutdown.rs +++ b/src/server/shutdown.rs @@ -54,7 +54,7 @@ where IO: AsyncRead + AsyncWrite + Unpin + Send + 'static, S: MakeServiceRef, S::Error: Into>, - B: HttpBody + Send + Sync + 'static, + B: HttpBody + 'static, B::Error: Into>, F: Future, E: ConnStreamExec<>::Future, B>, @@ -103,7 +103,7 @@ where I: AsyncRead + AsyncWrite + Unpin + Send + 'static, S: HttpService, E: ConnStreamExec, - S::ResBody: Send + Sync + 'static, + S::ResBody: 'static, ::Error: Into>, { type Future = @@ -119,7 +119,7 @@ where S: HttpService, S::Error: Into>, I: AsyncRead + AsyncWrite + Unpin, - S::ResBody: HttpBody + Send + 'static, + S::ResBody: HttpBody + 'static, ::Error: Into>, E: ConnStreamExec, {