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]]
[[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]]
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 };
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)
}
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");
// 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)]
// 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<Packet, ReadingError>;
pub type WritingResult = Result<(), WritingError>;