From 78967dea13bc55638ee0a7f5f2fa0774d1d5d1d7 Mon Sep 17 00:00:00 2001 From: Nikolay Kim Date: Wed, 24 Jan 2018 20:17:14 -0800 Subject: [PATCH] stop http context immediately --- src/context.rs | 3 ++- src/payload.rs | 2 +- src/ws/context.rs | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/context.rs b/src/context.rs index 76be616c..cdeb43d1 100644 --- a/src/context.rs +++ b/src/context.rs @@ -75,7 +75,8 @@ impl AsyncContext for HttpContext where A: Actor #[doc(hidden)] #[inline] fn waiting(&self) -> bool { - self.inner.wating() + self.inner.waiting() || self.inner.state() == ActorState::Stopping || + self.inner.state() == ActorState::Stopped } #[inline] fn cancel_future(&mut self, handle: SpawnHandle) -> bool { diff --git a/src/payload.rs b/src/payload.rs index 002034da..a7b00813 100644 --- a/src/payload.rs +++ b/src/payload.rs @@ -420,7 +420,7 @@ impl Inner { } pub fn readall(&mut self) -> Option { - 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 { let mut buf = BytesMut::with_capacity(len); for item in &self.items { diff --git a/src/ws/context.rs b/src/ws/context.rs index 74988674..2ad164b4 100644 --- a/src/ws/context.rs +++ b/src/ws/context.rs @@ -58,7 +58,7 @@ impl AsyncContext for WebsocketContext where A: Actor bool { - self.inner.wating() || self.inner.state() == ActorState::Stopping || + self.inner.waiting() || self.inner.state() == ActorState::Stopping || self.inner.state() == ActorState::Stopped }