diff --git a/actix-server/src/accept.rs b/actix-server/src/accept.rs index f48e6ee9..6064b849 100644 --- a/actix-server/src/accept.rs +++ b/actix-server/src/accept.rs @@ -190,10 +190,7 @@ impl Future for Accept { this.avail.set_available(handle.idx(), true); this.handles.push(handle); } - Interest::Pause => { - this.paused = true; - break; - } + Interest::Pause => this.paused = true, Interest::Resume => this.paused = false, Interest::Stop => return Poll::Ready(()), } diff --git a/actix-server/src/service.rs b/actix-server/src/service.rs index c6b2fcc4..0e539cd7 100644 --- a/actix-server/src/service.rs +++ b/actix-server/src/service.rs @@ -5,7 +5,6 @@ use std::task::{Context, Poll}; use actix_service::{Service, ServiceFactory as BaseServiceFactory}; use actix_utils::future::{ready, Ready}; use futures_core::future::LocalBoxFuture; -use log::error; use crate::socket::{FromStream, Stream}; use crate::worker::WorkerCounterGuard; @@ -63,20 +62,15 @@ where } fn call(&self, (guard, req): (WorkerCounterGuard, Stream)) -> Self::Future { - ready(match FromStream::from_mio(req) { - Ok(stream) => { - let f = self.service.call(stream); - actix_rt::spawn(async move { - let _ = f.await; - drop(guard); - }); - Ok(()) - } - Err(e) => { - error!("Can not convert to an async tcp stream: {}", e); - Err(()) - } - }) + let stream = FromStream::from_stream(req); + + let f = self.service.call(stream); + actix_rt::spawn(async move { + let _ = f.await; + drop(guard); + }); + + ready(Ok(())) } } diff --git a/actix-server/src/socket.rs b/actix-server/src/socket.rs index ab6fad3e..75f8e505 100644 --- a/actix-server/src/socket.rs +++ b/actix-server/src/socket.rs @@ -80,7 +80,7 @@ pub enum Stream { /// helper trait for converting mio stream to tokio stream. pub trait FromStream: Sized { - fn from_mio(stream: Stream) -> io::Result; + fn from_stream(stream: Stream) -> Self; } #[cfg(windows)] @@ -91,9 +91,9 @@ mod win_impl { // FIXME: This is a workaround and we need an efficient way to convert between mio and tokio stream impl FromStream for TcpStream { - fn from_mio(stream: MioStream) -> io::Result { + fn from_stream(stream: Stream) -> Self { match stream { - MioStream::Tcp(stream) => Ok(stream), + MioStream::Tcp(stream) => stream, } } } @@ -105,9 +105,9 @@ mod unix_impl { // FIXME: This is a workaround and we need an efficient way to convert between mio and tokio stream impl FromStream for TcpStream { - fn from_mio(stream: Stream) -> io::Result { + fn from_stream(stream: Stream) -> Self { match stream { - Stream::Tcp(stream) => Ok(stream), + Stream::Tcp(stream) => stream, Stream::Uds(_) => { panic!("Should not happen, bug in server impl"); } @@ -117,10 +117,10 @@ mod unix_impl { // FIXME: This is a workaround and we need an efficient way to convert between mio and tokio stream impl FromStream for actix_rt::net::UnixStream { - fn from_mio(stream: Stream) -> io::Result { + fn from_stream(stream: Stream) -> Self { match stream { Stream::Tcp(_) => panic!("Should not happen, bug in server impl"), - Stream::Uds(stream) => Ok(stream), + Stream::Uds(stream) => stream, } } }