From a8641e8dd205140af9206e82169ff5ad107c23f8 Mon Sep 17 00:00:00 2001 From: Ummon Date: Mon, 22 Dec 2014 13:22:33 +0100 Subject: [PATCH] Fix to the new nightly. --- lab1_rust/Cargo.lock | 16 ++++++++-------- lab1_rust/src/end_point.rs | 14 ++++++++------ lab1_rust/src/packet.rs | 4 ++-- 3 files changed, 18 insertions(+), 16 deletions(-) diff --git a/lab1_rust/Cargo.lock b/lab1_rust/Cargo.lock index d5a58e5..00d919b 100644 --- a/lab1_rust/Cargo.lock +++ b/lab1_rust/Cargo.lock @@ -2,7 +2,7 @@ name = "lab1_rust" version = "0.0.2" dependencies = [ - "openssl 0.2.3 (git+https://github.com/sfackler/rust-openssl.git)", + "openssl 0.2.7 (git+https://github.com/sfackler/rust-openssl.git)", ] [[package]] @@ -15,24 +15,24 @@ dependencies = [ [[package]] name = "openssl" -version = "0.2.3" -source = "git+https://github.com/sfackler/rust-openssl.git#9754b8e47db5faff2930ed070527d2d71e76e094" +version = "0.2.7" +source = "git+https://github.com/sfackler/rust-openssl.git#12d31ade9dca8006b23e36d7631e9113f6234fc0" dependencies = [ - "openssl-sys 0.2.3 (git+https://github.com/sfackler/rust-openssl.git)", + "openssl-sys 0.2.7 (git+https://github.com/sfackler/rust-openssl.git)", ] [[package]] name = "openssl-sys" -version = "0.2.3" -source = "git+https://github.com/sfackler/rust-openssl.git#9754b8e47db5faff2930ed070527d2d71e76e094" +version = "0.2.7" +source = "git+https://github.com/sfackler/rust-openssl.git#12d31ade9dca8006b23e36d7631e9113f6234fc0" dependencies = [ "libressl-pnacl-sys 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "pkg-config 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "pkg-config 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "pkg-config" -version = "0.1.1" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] diff --git a/lab1_rust/src/end_point.rs b/lab1_rust/src/end_point.rs index 97104c6..d2cedcb 100644 --- a/lab1_rust/src/end_point.rs +++ b/lab1_rust/src/end_point.rs @@ -1,6 +1,7 @@ use std::io; use std::io::{ MemWriter, Acceptor, Listener, TcpStream, IoResult, IoError, EndOfFile }; use std::io::net::tcp::{ TcpAcceptor, TcpListener }; +use std::thread::Thread; use packet; use packet::{ Packet, ReadingResult, PacketType }; use packet::PacketType::{ Command, Answer, Error }; @@ -30,18 +31,19 @@ impl Server { acceptor: acceptor.clone() }; - spawn(proc() { + Thread::spawn(move || { loop { for stream in acceptor.incoming() { match stream { - Ok(stream) => spawn(proc() { - Server::handle_client(EndPoint::new(stream, variant)); - }), + Ok(stream) => + Thread::spawn(move || { + Server::handle_client(EndPoint::new(stream, variant)); + }).detach(), _ => return } } } - }); + }).detach(); Ok(server) } @@ -236,7 +238,7 @@ impl Client { let mut nb_test_passed = 0; for (i, test) in range(1, tests.len()+1).zip(tests.iter_mut()) { - println!("===== Test case #{}:", i) + println!("===== Test case #{}:", i); if execute(test) { nb_test_passed += 1; println!("===== Test passed"); diff --git a/lab1_rust/src/packet.rs b/lab1_rust/src/packet.rs index ff6aa71..ec63d9e 100644 --- a/lab1_rust/src/packet.rs +++ b/lab1_rust/src/packet.rs @@ -29,7 +29,7 @@ pub enum ReadingError { // A macro to return a 'Err(ReadingError::IO(..))' in case of error. macro_rules! try_read_io( ($e:expr) => (match $e { Ok(e) => e, Err(e) => return Err(ReadingError::IO(e)) }) -) +); // There are all the errors that may occur when encrypting, authenticating and writing a packet. #[deriving(Show)] @@ -41,7 +41,7 @@ pub enum WritingError { // A macro to return a 'Err(WritingError::IO(..))' in case of error. macro_rules! try_write_io( ($e:expr) => (match $e { Ok(e) => e, Err(e) => return Err(WritingError::IO(e)) }) -) +); pub type ReadingResult = Result; pub type WritingResult = Result<(), WritingError>; -- 2.43.0