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.
This commit is contained in:
Shanil Puri 2014-10-21 19:09:59 -04:00
parent ccdd2910a2
commit fc7b3699ed
2 changed files with 12 additions and 3 deletions

View file

@ -88,6 +88,8 @@ fn run_server(receiver: Receiver<DevtoolsControlMsg>, port: u16) {
let actors = Arc::new(Mutex::new(registry));
let mut accepted_connections: Vec<TcpStream> = Vec::new();
/// Process the input from a single devtools client until EOF.
fn handle_client(actors: Arc<Mutex<ActorRegistry>>, mut stream: TcpStream) {
println!("connection established to {:?}", stream.peer_name().unwrap());
@ -178,9 +180,6 @@ fn run_server(receiver: Receiver<DevtoolsControlMsg>, 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<DevtoolsControlMsg>, 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<DevtoolsControlMsg>, port: u16) {
}
}
}
for connection in accepted_connections.iter_mut() {
let _read = connection.close_read();
let _write = connection.close_write();
}
}