From fc7b3699ed10bac38143e816af216c1db25dad30 Mon Sep 17 00:00:00 2001 From: Shanil Puri Date: Tue, 21 Oct 2014 19:09:59 -0400 Subject: [PATCH 1/2] Sending exit message to devtools to exit. Accepted and closed incoming streams Added header to for constant use. Removed extra spaces. Corrected spacing to conform to coding standards. Corrected spacing to conform to coding standards. Corrected spacing to conform with coding standards. Moving new import next to old import for devtools_traits as specified in comment. Removed method definition to include as inline code and changed to iter_mut. Using loops to exit devtools on server exit message and disconnected message to simply break as suggested in the comment. Removing TODO comment for completed functionality. Moved the operation for exit of devtools on servo closing outside the match loop. Removing trailing ';' and adding new line before connection closing loop. --- components/compositing/constellation.rs | 4 ++++ components/devtools/lib.rs | 11 ++++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/components/compositing/constellation.rs b/components/compositing/constellation.rs index 7bbf1ebb5fb..242163908c1 100644 --- a/components/compositing/constellation.rs +++ b/components/compositing/constellation.rs @@ -5,6 +5,7 @@ use pipeline::{Pipeline, CompositionPipeline}; use compositor_task::{CompositorProxy, FrameTreeUpdateMsg, LoadComplete, ShutdownComplete, SetLayerOrigin, SetIds}; +use devtools_traits; use devtools_traits::DevtoolsControlChan; use geom::rect::{Rect, TypedRect}; use geom::scale_factor::ScaleFactor; @@ -460,6 +461,9 @@ impl Constellation { } self.image_cache_task.exit(); self.resource_task.send(resource_task::Exit); + self.devtools_chan.as_ref().map(|chan| { + chan.send(devtools_traits::ServerExitMsg); + }); self.font_cache_task.exit(); self.compositor_proxy.send(ShutdownComplete); } diff --git a/components/devtools/lib.rs b/components/devtools/lib.rs index 6c756237c30..a6e5b78a55f 100644 --- a/components/devtools/lib.rs +++ b/components/devtools/lib.rs @@ -88,6 +88,8 @@ fn run_server(receiver: Receiver, port: u16) { let actors = Arc::new(Mutex::new(registry)); + let mut accepted_connections: Vec = Vec::new(); + /// Process the input from a single devtools client until EOF. fn handle_client(actors: Arc>, mut stream: TcpStream) { println!("connection established to {:?}", stream.peer_name().unwrap()); @@ -178,9 +180,6 @@ fn run_server(receiver: Receiver, port: u16) { // from multiple script tasks simultaneously. Polling for new connections // for 300ms and then checking the receiver is not a good compromise // (and makes Servo hang on exit if there's an open connection, no less). - - //TODO: make constellation send ServerExitMsg on shutdown. - // accept connections and process them, spawning a new tasks for each one loop { match acceptor.accept() { @@ -194,6 +193,7 @@ fn run_server(receiver: Receiver, port: u16) { Err(_e) => { /* connection failed */ } Ok(stream) => { let actors = actors.clone(); + accepted_connections.push(stream.clone()); spawn_named("DevtoolsClientHandler", proc() { // connection succeeded handle_client(actors, stream.clone()) @@ -201,4 +201,9 @@ fn run_server(receiver: Receiver, port: u16) { } } } + + for connection in accepted_connections.iter_mut() { + let _read = connection.close_read(); + let _write = connection.close_write(); + } } From d6e99cb26980f02cdc6d239a309a6092a9ad59c3 Mon Sep 17 00:00:00 2001 From: Shanil Puri Date: Mon, 17 Nov 2014 00:55:41 -0500 Subject: [PATCH 2/2] Spacing changes corrected. --- components/devtools/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/devtools/lib.rs b/components/devtools/lib.rs index a6e5b78a55f..af2709ebdc8 100644 --- a/components/devtools/lib.rs +++ b/components/devtools/lib.rs @@ -193,7 +193,7 @@ fn run_server(receiver: Receiver, port: u16) { Err(_e) => { /* connection failed */ } Ok(stream) => { let actors = actors.clone(); - accepted_connections.push(stream.clone()); + accepted_connections.push(stream.clone()); spawn_named("DevtoolsClientHandler", proc() { // connection succeeded handle_client(actors, stream.clone())