Skip to content

Commit

Permalink
test: clear deprecation warnings in tcp-stress
Browse files Browse the repository at this point in the history
Signed-off-by: Luca Bruno <lucab@debian.org>
  • Loading branch information
lucab committed May 14, 2016
1 parent 47ebc56 commit 22972b8
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/test/run-pass/tcp-stress.rs
Expand Up @@ -18,25 +18,26 @@ use std::io::prelude::*;
use std::net::{TcpListener, TcpStream};
use std::process;
use std::sync::mpsc::channel;
use std::time::Duration;
use std::thread::{self, Builder};

fn main() {
// This test has a chance to time out, try to not let it time out
thread::spawn(move|| -> () {
thread::sleep_ms(30 * 1000);
thread::sleep(Duration::from_secs(30));
process::exit(1);
});

let mut listener = TcpListener::bind("127.0.0.1:0").unwrap();
let listener = TcpListener::bind("127.0.0.1:0").unwrap();
let addr = listener.local_addr().unwrap();
thread::spawn(move || -> () {
loop {
let mut stream = match listener.accept() {
Ok(stream) => stream.0,
Err(error) => continue,
Err(_) => continue,
};
stream.read(&mut [0]);
stream.write(&[2]);
let _ = stream.read(&mut [0]);
let _ = stream.write(&[2]);
}
});

Expand All @@ -47,8 +48,8 @@ fn main() {
let res = Builder::new().stack_size(64 * 1024).spawn(move|| {
match TcpStream::connect(addr) {
Ok(mut stream) => {
stream.write(&[1]);
stream.read(&mut [0]);
let _ = stream.write(&[1]);
let _ = stream.read(&mut [0]);
},
Err(..) => {}
}
Expand Down

0 comments on commit 22972b8

Please sign in to comment.