diff --git a/actix-service/CHANGES.md b/actix-service/CHANGES.md index 81419ee1..fc8f68cd 100644 --- a/actix-service/CHANGES.md +++ b/actix-service/CHANGES.md @@ -1,5 +1,12 @@ # Changes +## [0.1.2] - 2018-12-12 + +### Fixed + +* Release future early for `.and_then()` and `.then()` combinators + + ## [0.1.1] - 2018-12-09 ### Added diff --git a/actix-service/Cargo.toml b/actix-service/Cargo.toml index 332d044a..ca1763ee 100644 --- a/actix-service/Cargo.toml +++ b/actix-service/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "actix-service" -version = "0.1.1" +version = "0.1.2" authors = ["Nikolay Kim "] description = "Actix Service" keywords = ["network", "framework", "async", "futures"] diff --git a/actix-service/src/and_then.rs b/actix-service/src/and_then.rs index 1e0649bd..f9b74468 100644 --- a/actix-service/src/and_then.rs +++ b/actix-service/src/and_then.rs @@ -61,7 +61,7 @@ where { b: Cell, fut_b: Option, - fut_a: A::Future, + fut_a: Option, } impl AndThenFuture @@ -69,10 +69,10 @@ where A: Service, B: Service, { - fn new(fut_a: A::Future, b: Cell) -> Self { + fn new(a: A::Future, b: Cell) -> Self { AndThenFuture { b, - fut_a, + fut_a: Some(a), fut_b: None, } } @@ -91,8 +91,9 @@ where return fut.poll(); } - match self.fut_a.poll() { + match self.fut_a.as_mut().expect("Bug in actix-service").poll() { Ok(Async::Ready(resp)) => { + let _ = self.fut_a.take(); self.fut_b = Some(self.b.get_mut().call(resp)); self.poll() } diff --git a/actix-service/src/then.rs b/actix-service/src/then.rs index 1cdb6214..3667553d 100644 --- a/actix-service/src/then.rs +++ b/actix-service/src/then.rs @@ -61,7 +61,7 @@ where { b: Cell, fut_b: Option, - fut_a: A::Future, + fut_a: Option, } impl ThenFuture @@ -69,10 +69,10 @@ where A: Service, B: Service>, { - fn new(fut_a: A::Future, b: Cell) -> Self { + fn new(a: A::Future, b: Cell) -> Self { ThenFuture { b, - fut_a, + fut_a: Some(a), fut_b: None, } } @@ -91,12 +91,14 @@ where return fut.poll(); } - match self.fut_a.poll() { + match self.fut_a.as_mut().expect("bug in actix-service").poll() { Ok(Async::Ready(resp)) => { + let _ = self.fut_a.take(); self.fut_b = Some(self.b.get_mut().call(Ok(resp))); self.poll() } Err(err) => { + let _ = self.fut_a.take(); self.fut_b = Some(self.b.get_mut().call(Err(err))); self.poll() }