mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-02 07:22:42 +00:00
SeqCst->Relaxed in std::net::test.
Relaxed is enough to have fetch_add(1) return each value only once (until it wraps around).
This commit is contained in:
parent
8b519f98e2
commit
b45a725cbc
@ -7,12 +7,12 @@ use crate::sync::atomic::{AtomicUsize, Ordering};
|
||||
static PORT: AtomicUsize = AtomicUsize::new(0);
|
||||
|
||||
pub fn next_test_ip4() -> SocketAddr {
|
||||
let port = PORT.fetch_add(1, Ordering::SeqCst) as u16 + base_port();
|
||||
let port = PORT.fetch_add(1, Ordering::Relaxed) as u16 + base_port();
|
||||
SocketAddr::V4(SocketAddrV4::new(Ipv4Addr::new(127, 0, 0, 1), port))
|
||||
}
|
||||
|
||||
pub fn next_test_ip6() -> SocketAddr {
|
||||
let port = PORT.fetch_add(1, Ordering::SeqCst) as u16 + base_port();
|
||||
let port = PORT.fetch_add(1, Ordering::Relaxed) as u16 + base_port();
|
||||
SocketAddr::V6(SocketAddrV6::new(Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0, 1), port, 0, 0))
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user