From 6801a38de50eb062fde85797feaf37301d9b1d34 Mon Sep 17 00:00:00 2001 From: Nikolay Kim Date: Tue, 12 Mar 2019 15:15:14 -0700 Subject: [PATCH] check readiness for all services --- actix-service/src/and_then.rs | 10 +++++++--- actix-service/src/and_then_apply_fn.rs | 10 +++++++--- actix-service/src/then.rs | 10 +++++++--- 3 files changed, 21 insertions(+), 9 deletions(-) diff --git a/actix-service/src/and_then.rs b/actix-service/src/and_then.rs index 5dbc343e..38a4a5b5 100644 --- a/actix-service/src/and_then.rs +++ b/actix-service/src/and_then.rs @@ -1,6 +1,6 @@ use std::marker::PhantomData; -use futures::{try_ready, Async, Future, Poll}; +use futures::{Async, Future, Poll}; use super::{IntoNewService, NewService, Service}; use crate::cell::Cell; @@ -48,8 +48,12 @@ where type Future = AndThenFuture; fn poll_ready(&mut self) -> Poll<(), Self::Error> { - try_ready!(self.a.poll_ready()); - self.b.get_mut().poll_ready() + let not_ready = self.a.poll_ready()?.is_not_ready(); + if self.b.get_mut().poll_ready()?.is_not_ready() || not_ready { + Ok(Async::NotReady) + } else { + Ok(Async::Ready(())) + } } fn call(&mut self, req: A::Request) -> Self::Future { diff --git a/actix-service/src/and_then_apply_fn.rs b/actix-service/src/and_then_apply_fn.rs index 41b536dc..423a8eec 100644 --- a/actix-service/src/and_then_apply_fn.rs +++ b/actix-service/src/and_then_apply_fn.rs @@ -1,6 +1,6 @@ use std::marker::PhantomData; -use futures::{try_ready, Async, Future, IntoFuture, Poll}; +use futures::{Async, Future, IntoFuture, Poll}; use super::{IntoNewService, IntoService, NewService, Service}; use crate::cell::Cell; @@ -71,8 +71,12 @@ where type Future = AndThenApplyFuture; fn poll_ready(&mut self) -> Poll<(), Self::Error> { - try_ready!(self.a.poll_ready()); - self.b.get_mut().poll_ready() + let not_ready = self.a.poll_ready()?.is_not_ready(); + if self.b.get_mut().poll_ready()?.is_not_ready() || not_ready { + Ok(Async::NotReady) + } else { + Ok(Async::Ready(())) + } } fn call(&mut self, req: A::Request) -> Self::Future { diff --git a/actix-service/src/then.rs b/actix-service/src/then.rs index c0a31bfd..d30f1780 100644 --- a/actix-service/src/then.rs +++ b/actix-service/src/then.rs @@ -1,6 +1,6 @@ use std::marker::PhantomData; -use futures::{try_ready, Async, Future, Poll}; +use futures::{Async, Future, Poll}; use super::{IntoNewService, NewService, Service}; use crate::cell::Cell; @@ -48,8 +48,12 @@ where type Future = ThenFuture; fn poll_ready(&mut self) -> Poll<(), Self::Error> { - try_ready!(self.a.poll_ready()); - self.b.get_mut().poll_ready() + let not_ready = self.a.poll_ready()?.is_not_ready(); + if self.b.get_mut().poll_ready()?.is_not_ready() || not_ready { + Ok(Async::NotReady) + } else { + Ok(Async::Ready(())) + } } fn call(&mut self, req: A::Request) -> Self::Future {