diff --git a/actix-utils/CHANGES.md b/actix-utils/CHANGES.md index 85e00989..c20a0e76 100644 --- a/actix-utils/CHANGES.md +++ b/actix-utils/CHANGES.md @@ -1,5 +1,9 @@ # Changes +## [1.0.3] - 2019-12-11 + +* Revert InOrder service changes + ## [1.0.2] - 2019-12-11 * Allow to create `framed::Dispatcher` with custom `mpsc::Receiver` diff --git a/actix-utils/Cargo.toml b/actix-utils/Cargo.toml index b1654fbc..78879a79 100644 --- a/actix-utils/Cargo.toml +++ b/actix-utils/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "actix-utils" -version = "1.0.2" +version = "1.0.3" authors = ["Nikolay Kim "] description = "Actix utils - various actix net related services" keywords = ["network", "framework", "async", "futures"] diff --git a/actix-utils/src/order.rs b/actix-utils/src/order.rs index a5a6cc1f..15bf6361 100644 --- a/actix-utils/src/order.rs +++ b/actix-utils/src/order.rs @@ -1,6 +1,7 @@ use std::collections::VecDeque; use std::convert::Infallible; use std::fmt; +use std::rc::Rc; use std::future::Future; use std::marker::PhantomData; use std::pin::Pin; @@ -10,6 +11,7 @@ use actix_service::{IntoService, Service, Transform}; use futures::future::{ok, Ready}; use crate::oneshot; +use crate::task::LocalWaker; struct Record { rx: oneshot::Receiver>, @@ -103,6 +105,7 @@ where pub struct InOrderService { service: S, + waker: Rc, acks: VecDeque>, } @@ -120,6 +123,7 @@ where Self { service: service.into_service(), acks: VecDeque::new(), + waker: Rc::new(LocalWaker::new()), } } } @@ -137,6 +141,9 @@ where type Future = InOrderServiceResponse; fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll> { + // poll_ready could be called from different task + self.waker.register(cx.waker()); + // check acks while !self.acks.is_empty() { let rec = self.acks.front_mut().unwrap(); @@ -165,9 +172,11 @@ where let (tx2, rx2) = oneshot::channel(); self.acks.push_back(Record { rx: rx1, tx: tx2 }); + let waker = self.waker.clone(); let fut = self.service.call(request); actix_rt::spawn(async move { let res = fut.await; + waker.wake(); let _ = tx1.send(res); });