Closed
Description
Machine: Ubuntu 13.10, 64-bit
rustc version: 0.10-pre (master)
Steps to reproduce:
- Compile this code:
extern mod native;
use std::io::{io_error, Listener, Acceptor};
use std::io::net::ip::SocketAddr;
use std::io::net::tcp::{TcpListener};
#[start]
fn start(argc: int, argv: **u8) -> int {
do native::start(argc, argv) {
let mut acceptor = match TcpListener::bind(
from_str::<SocketAddr>("127.0.0.1:8021").unwrap()).listen() {
None => {
error!("bind or listen failed :-(");
return;
},
Some(acceptor) => acceptor,
};
let mut error = None;
io_error::cond.trap(|e| {
error = Some(e);
}).inside(|| {
println!("Visit http://127.0.0.1:8021");
acceptor.accept();
println!("Got a stream!");
});
}
}
- Run the executable.
- Visit http://127.0.0.1:8021 in a browser (the program will terminate).
- Run the executable again.
Now you should see a task failure like this:
task '<unnamed>' failed at 'Unhandled condition: io_error: io::IoError{kind: ConnectionRefused, desc: "address in use", detail: Some(~"Address already in use")}', /build/buildd/rust-nightly-201401260405~897a0a3~saucy/src/libstd/condition.rs:139