|
| 1 | +From 073bae1e73f31f0f5a6acb6903cd88136dd1f41c Mon Sep 17 00:00:00 2001 |
| 2 | +From: Dominik Hassler <hadfl@omnios.org> |
| 3 | +Date: Sat, 22 Feb 2025 19:16:00 +0000 |
| 4 | +Subject: [PATCH] add illumos support |
| 5 | + |
| 6 | +diff -wpruN --no-dereference '--exclude=*.orig' a~/libs/hbb_common/src/tcp.rs a/libs/hbb_common/src/tcp.rs |
| 7 | +--- a~/libs/hbb_common/src/tcp.rs 1970-01-01 00:00:00 |
| 8 | ++++ a/libs/hbb_common/src/tcp.rs 1970-01-01 00:00:00 |
| 9 | +@@ -68,10 +68,11 @@ pub(crate) fn new_socket(addr: std::net: |
| 10 | + std::net::SocketAddr::V6(..) => TcpSocket::new_v6()?, |
| 11 | + }; |
| 12 | + if reuse { |
| 13 | +- // windows has no reuse_port, but it's reuse_address |
| 14 | ++ // windows has no reuse_port, but its reuse_address |
| 15 | + // almost equals to unix's reuse_port + reuse_address, |
| 16 | + // though may introduce nondeterministic behavior |
| 17 | +- #[cfg(unix)] |
| 18 | ++ // illumos has no support for SO_REUSEPORT |
| 19 | ++ #[cfg(all(unix, not(target_os = "illumos")))] |
| 20 | + socket.set_reuseport(true).ok(); |
| 21 | + socket.set_reuseaddr(true).ok(); |
| 22 | + } |
| 23 | +@@ -226,6 +227,8 @@ pub async fn listen_any(port: u16) -> Re |
| 24 | + if let Ok(mut socket) = TcpSocket::new_v6() { |
| 25 | + #[cfg(unix)] |
| 26 | + { |
| 27 | ++ // illumos has no support for SO_REUSEPORT |
| 28 | ++ #[cfg(not(target_os = "illumos"))] |
| 29 | + socket.set_reuseport(true).ok(); |
| 30 | + socket.set_reuseaddr(true).ok(); |
| 31 | + use std::os::unix::io::{FromRawFd, IntoRawFd}; |
| 32 | +diff -wpruN --no-dereference '--exclude=*.orig' a~/libs/hbb_common/src/udp.rs a/libs/hbb_common/src/udp.rs |
| 33 | +--- a~/libs/hbb_common/src/udp.rs 1970-01-01 00:00:00 |
| 34 | ++++ a/libs/hbb_common/src/udp.rs 1970-01-01 00:00:00 |
| 35 | +@@ -20,10 +20,11 @@ fn new_socket(addr: SocketAddr, reuse: b |
| 36 | + SocketAddr::V6(..) => Socket::new(Domain::ipv6(), Type::dgram(), None), |
| 37 | + }?; |
| 38 | + if reuse { |
| 39 | +- // windows has no reuse_port, but it's reuse_address |
| 40 | ++ // windows has no reuse_port, but its reuse_address |
| 41 | + // almost equals to unix's reuse_port + reuse_address, |
| 42 | + // though may introduce nondeterministic behavior |
| 43 | +- #[cfg(unix)] |
| 44 | ++ // illumos has no support for SO_REUSEPORT |
| 45 | ++ #[cfg(all(unix, not(target_os = "illumos")))] |
| 46 | + socket.set_reuse_port(true).ok(); |
| 47 | + socket.set_reuse_address(true).ok(); |
| 48 | + } |
0 commit comments