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
1 changed files with 2 additions and 2 deletions
|
|
@ -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…
Add table
Add a link
Reference in a new issue