diff --git a/Cargo.toml b/Cargo.toml index 78e54d35..30ca6388 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,3 +23,5 @@ actix-tls = { path = "actix-tls" } actix-tracing = { path = "actix-tracing" } actix-utils = { path = "actix-utils" } bytestring = { path = "bytestring" } + +tokio = { git = "https://github.com/fakeshadow/tokio", branch = "feature/net_poll_ready" } \ No newline at end of file diff --git a/actix-rt/Cargo.toml b/actix-rt/Cargo.toml index 92f10b85..126056ec 100644 --- a/actix-rt/Cargo.toml +++ b/actix-rt/Cargo.toml @@ -26,7 +26,7 @@ macros = ["actix-macros"] actix-macros = { version = "0.2.0", optional = true } futures-core = { version = "0.3", default-features = false } -tokio = { version = "1.2", features = ["rt", "net", "parking_lot", "signal", "sync", "time"] } +tokio = { version = "1.3", features = ["rt", "net", "parking_lot", "signal", "sync", "time"] } [dev-dependencies] tokio = { version = "1.2", features = ["full"] } diff --git a/actix-rt/src/lib.rs b/actix-rt/src/lib.rs index e21cd651..4afa8ea0 100644 --- a/actix-rt/src/lib.rs +++ b/actix-rt/src/lib.rs @@ -72,8 +72,12 @@ pub mod signal { pub mod net { //! TCP/UDP/Unix bindings (mostly Tokio re-exports). - use std::task::{Context, Poll}; + use std::{ + io, + task::{Context, Poll}, + }; + pub use tokio::io::Ready; use tokio::io::{AsyncRead, AsyncWrite}; pub use tokio::net::UdpSocket; pub use tokio::net::{TcpListener, TcpSocket, TcpStream}; @@ -86,32 +90,32 @@ pub mod net { /// Poll stream and check read readiness of Self. /// /// See [tokio::net::TcpStream::poll_read_ready] for detail on intended use. - fn poll_read_ready(&self, cx: &mut Context<'_>) -> Poll>; + fn poll_read_ready(&self, cx: &mut Context<'_>) -> Poll>; /// Poll stream and check write readiness of Self. /// /// See [tokio::net::TcpStream::poll_write_ready] for detail on intended use. - fn poll_write_ready(&self, cx: &mut Context<'_>) -> Poll>; + fn poll_write_ready(&self, cx: &mut Context<'_>) -> Poll>; } impl ActixStream for TcpStream { - fn poll_read_ready(&self, cx: &mut Context<'_>) -> Poll> { - TcpStream::poll_read_ready(self, cx) + fn poll_read_ready(&self, cx: &mut Context<'_>) -> Poll> { + TcpStream::poll_ready(self, cx) } - fn poll_write_ready(&self, cx: &mut Context<'_>) -> Poll> { - TcpStream::poll_write_ready(self, cx) + fn poll_write_ready(&self, cx: &mut Context<'_>) -> Poll> { + TcpStream::poll_ready(self, cx) } } #[cfg(unix)] impl ActixStream for UnixStream { - fn poll_read_ready(&self, cx: &mut Context<'_>) -> Poll> { - UnixStream::poll_read_ready(self, cx) + fn poll_read_ready(&self, cx: &mut Context<'_>) -> Poll> { + UnixStream::poll_ready(self, cx) } - fn poll_write_ready(&self, cx: &mut Context<'_>) -> Poll> { - UnixStream::poll_write_ready(self, cx) + fn poll_write_ready(&self, cx: &mut Context<'_>) -> Poll> { + UnixStream::poll_ready(self, cx) } } } diff --git a/actix-tls/src/accept/nativetls.rs b/actix-tls/src/accept/nativetls.rs index 98a103a8..614bdad3 100644 --- a/actix-tls/src/accept/nativetls.rs +++ b/actix-tls/src/accept/nativetls.rs @@ -6,7 +6,7 @@ use std::{ }; use actix_codec::{AsyncRead, AsyncWrite, ReadBuf}; -use actix_rt::net::ActixStream; +use actix_rt::net::{ActixStream, Ready}; use actix_service::{Service, ServiceFactory}; use actix_utils::counter::Counter; use futures_core::future::LocalBoxFuture; @@ -80,11 +80,11 @@ impl AsyncWrite for TlsStream { } impl ActixStream for TlsStream { - fn poll_read_ready(&self, cx: &mut Context<'_>) -> Poll> { + fn poll_read_ready(&self, cx: &mut Context<'_>) -> Poll> { T::poll_read_ready((&**self).get_ref().get_ref().get_ref(), cx) } - fn poll_write_ready(&self, cx: &mut Context<'_>) -> Poll> { + fn poll_write_ready(&self, cx: &mut Context<'_>) -> Poll> { T::poll_write_ready((&**self).get_ref().get_ref().get_ref(), cx) } } diff --git a/actix-tls/src/accept/openssl.rs b/actix-tls/src/accept/openssl.rs index f94e3c2d..4afcdcab 100644 --- a/actix-tls/src/accept/openssl.rs +++ b/actix-tls/src/accept/openssl.rs @@ -7,7 +7,7 @@ use std::{ }; use actix_codec::{AsyncRead, AsyncWrite, ReadBuf}; -use actix_rt::net::ActixStream; +use actix_rt::net::{ActixStream, Ready}; use actix_service::{Service, ServiceFactory}; use actix_utils::counter::{Counter, CounterGuard}; use futures_core::{future::LocalBoxFuture, ready}; @@ -82,11 +82,11 @@ impl AsyncWrite for TlsStream { } impl ActixStream for TlsStream { - fn poll_read_ready(&self, cx: &mut Context<'_>) -> Poll> { + fn poll_read_ready(&self, cx: &mut Context<'_>) -> Poll> { T::poll_read_ready((&**self).get_ref(), cx) } - fn poll_write_ready(&self, cx: &mut Context<'_>) -> Poll> { + fn poll_write_ready(&self, cx: &mut Context<'_>) -> Poll> { T::poll_write_ready((&**self).get_ref(), cx) } } diff --git a/actix-tls/src/accept/rustls.rs b/actix-tls/src/accept/rustls.rs index 753d68ac..ffac687a 100644 --- a/actix-tls/src/accept/rustls.rs +++ b/actix-tls/src/accept/rustls.rs @@ -8,7 +8,7 @@ use std::{ }; use actix_codec::{AsyncRead, AsyncWrite, ReadBuf}; -use actix_rt::net::ActixStream; +use actix_rt::net::{ActixStream, Ready}; use actix_service::{Service, ServiceFactory}; use actix_utils::counter::{Counter, CounterGuard}; use futures_core::future::LocalBoxFuture; @@ -82,11 +82,11 @@ impl AsyncWrite for TlsStream { } impl ActixStream for TlsStream { - fn poll_read_ready(&self, cx: &mut Context<'_>) -> Poll> { + fn poll_read_ready(&self, cx: &mut Context<'_>) -> Poll> { T::poll_read_ready((&**self).get_ref().0, cx) } - fn poll_write_ready(&self, cx: &mut Context<'_>) -> Poll> { + fn poll_write_ready(&self, cx: &mut Context<'_>) -> Poll> { T::poll_write_ready((&**self).get_ref().0, cx) } }