1
0
mirror of https://github.com/actix/actix-extras.git synced 2024-11-28 09:42:40 +01:00

stop http context immediately

This commit is contained in:
Nikolay Kim 2018-01-24 20:17:14 -08:00
parent 58a5d493b7
commit 78967dea13
3 changed files with 4 additions and 3 deletions

View File

@ -75,7 +75,8 @@ impl<A, S> AsyncContext<A> for HttpContext<A, S> where A: Actor<Context=Self>
#[doc(hidden)] #[doc(hidden)]
#[inline] #[inline]
fn waiting(&self) -> bool { fn waiting(&self) -> bool {
self.inner.wating() self.inner.waiting() || self.inner.state() == ActorState::Stopping ||
self.inner.state() == ActorState::Stopped
} }
#[inline] #[inline]
fn cancel_future(&mut self, handle: SpawnHandle) -> bool { fn cancel_future(&mut self, handle: SpawnHandle) -> bool {

View File

@ -420,7 +420,7 @@ impl Inner {
} }
pub fn readall(&mut self) -> Option<Bytes> { pub fn readall(&mut self) -> Option<Bytes> {
let len = self.items.iter().fold(0, |cur, item| cur + item.len()); let len = self.items.iter().map(|b| b.len()).sum();
if len > 0 { if len > 0 {
let mut buf = BytesMut::with_capacity(len); let mut buf = BytesMut::with_capacity(len);
for item in &self.items { for item in &self.items {

View File

@ -58,7 +58,7 @@ impl<A, S> AsyncContext<A> for WebsocketContext<A, S> where A: Actor<Context=Sel
#[doc(hidden)] #[doc(hidden)]
#[inline] #[inline]
fn waiting(&self) -> bool { fn waiting(&self) -> bool {
self.inner.wating() || self.inner.state() == ActorState::Stopping || self.inner.waiting() || self.inner.state() == ActorState::Stopping ||
self.inner.state() == ActorState::Stopped self.inner.state() == ActorState::Stopped
} }