Commit c5a16db9 authored by Steven Fackler's avatar Steven Fackler
Browse files

Fix dtls tests

There's a reason static mut is unsafe...
parent 483e0b1f
Loading
Loading
Loading
Loading
+8 −8
Original line number Diff line number Diff line
@@ -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)
    }
}