Fix dtls tests

There's a reason static mut is unsafe...
This commit is contained in:
Steven Fackler 2015-04-08 22:10:13 -07:00
parent 483e0b1f0a
commit c5a16db97e
1 changed files with 8 additions and 8 deletions

View File

@ -29,15 +29,15 @@ use ssl::SslMethod::Dtlsv1;
#[cfg(feature="dtlsv1")]
use connected_socket::Connect;
#[cfg(test)]
#[cfg(feature = "dtlsv1")]
mod udp {
static mut udp_port:u16 = 15410;
use std::sync::atomic::{AtomicUsize, ATOMIC_USIZE_INIT, Ordering};
static UDP_PORT: AtomicUsize = ATOMIC_USIZE_INIT;
pub fn next_server<'a>() -> String {
unsafe {
udp_port += 1;
format!("127.0.0.1:{}", udp_port)
}
let diff = UDP_PORT.fetch_add(1, Ordering::SeqCst);
format!("127.0.0.1:{}", 15411 + diff)
}
}