|
|
@@ -62,10 +62,11 @@ fn new_socket(addr: std::net::SocketAddr, reuse: bool) -> Result<TcpSocket, std:
|
|
62
|
62
|
std::net::SocketAddr::V6(..) => TcpSocket::new_v6()?,
|
|
63
|
63
|
};
|
|
64
|
64
|
if reuse {
|
|
65
|
|
- // windows has no reuse_port, but it's reuse_address
|
|
|
65
|
+ // windows has no reuse_port, but its reuse_address
|
|
66
|
66
|
// almost equals to unix's reuse_port + reuse_address,
|
|
67
|
|
- // though may introduce nondeterministic behavior
|
|
68
|
|
- #[cfg(unix)]
|
|
|
67
|
+ // though may introduce nondeterministic behavior.
|
|
|
68
|
+ // illumos has no support for SO_REUSEPORT
|
|
|
69
|
+ #[cfg(all(unix, not(target_os = "illumos")))]
|
|
69
|
70
|
socket.set_reuseport(true)?;
|
|
70
|
71
|
socket.set_reuseaddr(true)?;
|
|
71
|
72
|
}
|
|
|
@@ -263,10 +264,11 @@ pub async fn new_listener<T: ToSocketAddrs>(addr: T, reuse: bool) -> ResultType<
|
|
263
|
264
|
pub async fn listen_any(port: u16, reuse: bool) -> ResultType<TcpListener> {
|
|
264
|
265
|
if let Ok(mut socket) = TcpSocket::new_v6() {
|
|
265
|
266
|
if reuse {
|
|
266
|
|
- // windows has no reuse_port, but it's reuse_address
|
|
|
267
|
+ // windows has no reuse_port, but its reuse_address
|
|
267
|
268
|
// almost equals to unix's reuse_port + reuse_address,
|
|
268
|
|
- // though may introduce nondeterministic behavior
|
|
269
|
|
- #[cfg(unix)]
|
|
|
269
|
+ // though may introduce nondeterministic behavior.
|
|
|
270
|
+ // illumos has no support for SO_REUSEPORT
|
|
|
271
|
+ #[cfg(all(unix, not(target_os = "illumos")))]
|
|
270
|
272
|
socket.set_reuseport(true).ok();
|
|
271
|
273
|
socket.set_reuseaddr(true).ok();
|
|
272
|
274
|
}
|