From 21c289d7e4432c18ec26d24aa951f07f461650a7 Mon Sep 17 00:00:00 2001
From: Nikolay Kim <fafhrd91@gmail.com>
Date: Tue, 12 Mar 2019 16:03:05 -0700
Subject: [PATCH] fix InOrderService::poll_ready() nested service rediness
 check

---
 actix-server/Cargo.toml  |  2 +-
 actix-utils/CHANGES.md   |  2 ++
 actix-utils/Cargo.toml   |  2 +-
 actix-utils/src/order.rs | 10 ++++++----
 4 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/actix-server/Cargo.toml b/actix-server/Cargo.toml
index 0443589f..2bbe27ab 100644
--- a/actix-server/Cargo.toml
+++ b/actix-server/Cargo.toml
@@ -33,7 +33,7 @@ ssl = ["openssl", "tokio-openssl"]
 rust-tls = ["rustls", "tokio-rustls", "webpki", "webpki-roots"]
 
 [dependencies]
-actix-rt = "0.2.0"
+actix-rt = "0.2.1"
 actix-service = "0.3.3"
 actix-server-config = { path="../actix-server-config" }
 
diff --git a/actix-utils/CHANGES.md b/actix-utils/CHANGES.md
index c11e13ad..7bb703e9 100644
--- a/actix-utils/CHANGES.md
+++ b/actix-utils/CHANGES.md
@@ -10,6 +10,8 @@
 
 * Fix `InFlightService::poll_ready()` nested service readiness check
 
+* Fix `InOrderService::poll_ready()` nested service readiness check
+
 
 ## [0.3.3] - 2019-03-09
 
diff --git a/actix-utils/Cargo.toml b/actix-utils/Cargo.toml
index 79530e9f..8ed1c549 100644
--- a/actix-utils/Cargo.toml
+++ b/actix-utils/Cargo.toml
@@ -27,4 +27,4 @@ tokio-current-thread = "0.1.4"
 log = "0.4"
 
 [dev-dependencies]
-actix-rt = "0.2"
+actix-rt = "0.2.1"
diff --git a/actix-utils/src/order.rs b/actix-utils/src/order.rs
index 2b29a284..e40536c7 100644
--- a/actix-utils/src/order.rs
+++ b/actix-utils/src/order.rs
@@ -140,9 +140,6 @@ where
         // poll_ready could be called from different task
         self.task.register();
 
-        // check nested service
-        self.service.poll_ready().map_err(InOrderError::Service)?;
-
         // check acks
         while !self.acks.is_empty() {
             let rec = self.acks.front_mut().unwrap();
@@ -156,7 +153,12 @@ where
             }
         }
 
-        Ok(Async::Ready(()))
+        // check nested service
+        if let Async::NotReady = self.service.poll_ready().map_err(InOrderError::Service)? {
+            Ok(Async::NotReady)
+        } else {
+            Ok(Async::Ready(()))
+        }
     }
 
     fn call(&mut self, request: S::Request) -> Self::Future {