Skip to content

Commit b45a725

Browse files
committed
SeqCst->Relaxed in std::net::test.
Relaxed is enough to have fetch_add(1) return each value only once (until it wraps around).
1 parent 8b519f9 commit b45a725

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

library/std/src/net/test.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ use crate::sync::atomic::{AtomicUsize, Ordering};
77
static PORT: AtomicUsize = AtomicUsize::new(0);
88

99
pub fn next_test_ip4() -> SocketAddr {
10-
let port = PORT.fetch_add(1, Ordering::SeqCst) as u16 + base_port();
10+
let port = PORT.fetch_add(1, Ordering::Relaxed) as u16 + base_port();
1111
SocketAddr::V4(SocketAddrV4::new(Ipv4Addr::new(127, 0, 0, 1), port))
1212
}
1313

1414
pub fn next_test_ip6() -> SocketAddr {
15-
let port = PORT.fetch_add(1, Ordering::SeqCst) as u16 + base_port();
15+
let port = PORT.fetch_add(1, Ordering::Relaxed) as u16 + base_port();
1616
SocketAddr::V6(SocketAddrV6::new(Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0, 1), port, 0, 0))
1717
}
1818

0 commit comments

Comments
 (0)