From 58de9dcf56b29942fecf934e8b6bf27ed18c3a60 Mon Sep 17 00:00:00 2001 From: Nikolay Kim Date: Mon, 30 Oct 2017 14:49:20 -0700 Subject: [PATCH] added new cancel_future_on_stop --- Cargo.toml | 2 +- README.md | 1 - examples/websocket-chat/src/main.rs | 8 ++++---- src/context.rs | 6 ++++++ 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 4b163aed..9d29f7a3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,7 +15,7 @@ build = "build.rs" [badges] travis-ci = { repository = "actix/actix-web", branch = "master" } -appveyor = { repository = "fafhrd91/actix-web-hdy9d" } +appveyor = { repository = "actix/actix-web" } codecov = { repository = "actix/actix-web", branch = "master", service = "github" } [lib] diff --git a/README.md b/README.md index da6bb866..b634cec6 100644 --- a/README.md +++ b/README.md @@ -110,7 +110,6 @@ fn main() { .route_handler("/", StaticFiles::new("examples/static/", true))) .serve::<_, ()>("127.0.0.1:8080").unwrap(); - println!("Started http server: 127.0.0.1:8080"); Arbiter::system().send(msgs::SystemExit(0)); let _ = sys.run(); } diff --git a/examples/websocket-chat/src/main.rs b/examples/websocket-chat/src/main.rs index 1e436d16..14f93b91 100644 --- a/examples/websocket-chat/src/main.rs +++ b/examples/websocket-chat/src/main.rs @@ -211,10 +211,10 @@ fn main() { // redirect to websocket.html .resource("/", |r| r.handler(Method::GET, |req, payload, state| { - httpcodes::HTTPFound - .builder() - .header("LOCATION", "/static/websocket.html") - .body(Body::Empty) + Ok(httpcodes::HTTPFound + .builder() + .header("LOCATION", "/static/websocket.html") + .body(Body::Empty)?) })) // websocket .resource("/ws/", |r| r.get::()) diff --git a/src/context.rs b/src/context.rs index 81fcc4a6..04f39e3f 100644 --- a/src/context.rs +++ b/src/context.rs @@ -35,6 +35,7 @@ pub struct HttpContext where A: Actor> + Route, impl IoContext for HttpContext where A: Actor + Route { fn disconnected(&mut self) { + self.items.stop(); self.disconnected = true; if self.state == ActorState::Running { self.state = ActorState::Stopping; @@ -46,6 +47,7 @@ impl ActorContext for HttpContext where A: Actor + Route { /// Stop actor execution fn stop(&mut self) { + self.items.stop(); self.address.close(); if self.state == ActorState::Running { self.state = ActorState::Stopping; @@ -85,6 +87,10 @@ impl AsyncContext for HttpContext where A: Actor + Route self.modified = true; self.items.cancel_future(handle) } + + fn cancel_future_on_stop(&mut self, handle: SpawnHandle) { + self.items.cancel_future_on_stop(handle) + } } #[doc(hidden)]