aboutsummaryrefslogtreecommitdiffhomepage
path: root/libs/hbb_common/src/tcp.rs
diff options
context:
space:
mode:
authorDominik Hassler <[email protected]>2024-06-29 16:25:47 +0200
committerGitHub <[email protected]>2024-06-29 22:25:47 +0800
commit041a603173513a5958dc8df836b26344707207cb (patch)
tree810823174c98cc1510378a19579b2ff4d6fef02c /libs/hbb_common/src/tcp.rs
parente40994d62e5ca066e0b4560a368927bdd21c31b9 (diff)
downloadrustdesk-server-041a603173513a5958dc8df836b26344707207cb.tar.gz
rustdesk-server-041a603173513a5958dc8df836b26344707207cb.zip
add illumos support (#433)
Diffstat (limited to 'libs/hbb_common/src/tcp.rs')
-rw-r--r--libs/hbb_common/src/tcp.rs14
1 files changed, 8 insertions, 6 deletions
diff --git a/libs/hbb_common/src/tcp.rs b/libs/hbb_common/src/tcp.rs
index 046d901..e483abf 100644
--- a/libs/hbb_common/src/tcp.rs
+++ b/libs/hbb_common/src/tcp.rs
@@ -62,10 +62,11 @@ fn new_socket(addr: std::net::SocketAddr, reuse: bool) -> Result<TcpSocket, std:
std::net::SocketAddr::V6(..) => TcpSocket::new_v6()?,
};
if reuse {
- // windows has no reuse_port, but it's reuse_address
+ // windows has no reuse_port, but its reuse_address
// almost equals to unix's reuse_port + reuse_address,
- // though may introduce nondeterministic behavior
- #[cfg(unix)]
+ // though may introduce nondeterministic behavior.
+ // illumos has no support for SO_REUSEPORT
+ #[cfg(all(unix, not(target_os = "illumos")))]
socket.set_reuseport(true)?;
socket.set_reuseaddr(true)?;
}
@@ -263,10 +264,11 @@ pub async fn new_listener<T: ToSocketAddrs>(addr: T, reuse: bool) -> ResultType<
pub async fn listen_any(port: u16, reuse: bool) -> ResultType<TcpListener> {
if let Ok(mut socket) = TcpSocket::new_v6() {
if reuse {
- // windows has no reuse_port, but it's reuse_address
+ // windows has no reuse_port, but its reuse_address
// almost equals to unix's reuse_port + reuse_address,
- // though may introduce nondeterministic behavior
- #[cfg(unix)]
+ // though may introduce nondeterministic behavior.
+ // illumos has no support for SO_REUSEPORT
+ #[cfg(all(unix, not(target_os = "illumos")))]
socket.set_reuseport(true).ok();
socket.set_reuseaddr(true).ok();
}