Skip to content

Commit 041a603

Browse files
authored
add illumos support (#433)
1 parent e40994d commit 041a603

2 files changed

Lines changed: 12 additions & 9 deletions

File tree

libs/hbb_common/src/tcp.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,11 @@ fn new_socket(addr: std::net::SocketAddr, reuse: bool) -> Result<TcpSocket, std:
6262
std::net::SocketAddr::V6(..) => TcpSocket::new_v6()?,
6363
};
6464
if reuse {
65-
// windows has no reuse_port, but it's reuse_address
65+
// windows has no reuse_port, but its reuse_address
6666
// 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")))]
6970
socket.set_reuseport(true)?;
7071
socket.set_reuseaddr(true)?;
7172
}
@@ -263,10 +264,11 @@ pub async fn new_listener<T: ToSocketAddrs>(addr: T, reuse: bool) -> ResultType<
263264
pub async fn listen_any(port: u16, reuse: bool) -> ResultType<TcpListener> {
264265
if let Ok(mut socket) = TcpSocket::new_v6() {
265266
if reuse {
266-
// windows has no reuse_port, but it's reuse_address
267+
// windows has no reuse_port, but its reuse_address
267268
// 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")))]
270272
socket.set_reuseport(true).ok();
271273
socket.set_reuseaddr(true).ok();
272274
}

libs/hbb_common/src/udp.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,11 @@ fn new_socket(addr: SocketAddr, reuse: bool, buf_size: usize) -> Result<Socket,
2020
SocketAddr::V6(..) => Socket::new(Domain::ipv6(), Type::dgram(), None),
2121
}?;
2222
if reuse {
23-
// windows has no reuse_port, but it's reuse_address
23+
// windows has no reuse_port, but its reuse_address
2424
// almost equals to unix's reuse_port + reuse_address,
25-
// though may introduce nondeterministic behavior
26-
#[cfg(unix)]
25+
// though may introduce nondeterministic behavior.
26+
// illumos has no support for SO_REUSEPORT
27+
#[cfg(all(unix, not(target_os = "illumos")))]
2728
socket.set_reuse_port(true)?;
2829
socket.set_reuse_address(true)?;
2930
}

0 commit comments

Comments
 (0)