Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for illumos target #54

Merged
merged 1 commit into from
Mar 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions src/socket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -709,7 +709,11 @@ impl Socket {
///
/// This function is only available on Unix when the `reuseport` feature is
/// enabled.
#[cfg(all(unix, not(target_os = "solaris"), feature = "reuseport"))]
#[cfg(all(
unix,
not(any(target_os = "solaris", target_os = "illumos")),
feature = "reuseport"
))]
pub fn reuse_port(&self) -> io::Result<bool> {
self.inner.reuse_port()
}
Expand All @@ -722,7 +726,11 @@ impl Socket {
///
/// This function is only available on Unix when the `reuseport` feature is
/// enabled.
#[cfg(all(unix, not(target_os = "solaris"), feature = "reuseport"))]
#[cfg(all(
unix,
not(any(target_os = "solaris", target_os = "illumos")),
feature = "reuseport"
))]
pub fn set_reuse_port(&self, reuse: bool) -> io::Result<()> {
self.inner.set_reuse_port(reuse)
}
Expand Down
15 changes: 12 additions & 3 deletions src/sys/unix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ cfg_if::cfg_if! {
if #[cfg(any(target_os = "dragonfly", target_os = "freebsd",
target_os = "ios", target_os = "macos",
target_os = "openbsd", target_os = "netbsd",
target_os = "solaris", target_os = "haiku"))] {
target_os = "solaris", target_os = "illumos",
target_os = "haiku"))] {
use libc::IPV6_JOIN_GROUP as IPV6_ADD_MEMBERSHIP;
use libc::IPV6_LEAVE_GROUP as IPV6_DROP_MEMBERSHIP;
} else {
Expand Down Expand Up @@ -727,15 +728,23 @@ impl Socket {
}
}

#[cfg(all(unix, not(target_os = "solaris"), feature = "reuseport"))]
#[cfg(all(
unix,
not(any(target_os = "solaris", target_os = "illumos")),
feature = "reuseport"
))]
pub fn reuse_port(&self) -> io::Result<bool> {
unsafe {
let raw: c_int = self.getsockopt(libc::SOL_SOCKET, libc::SO_REUSEPORT)?;
Ok(raw != 0)
}
}

#[cfg(all(unix, not(target_os = "solaris"), feature = "reuseport"))]
#[cfg(all(
unix,
not(any(target_os = "solaris", target_os = "illumos")),
feature = "reuseport"
))]
pub fn set_reuse_port(&self, reuse: bool) -> io::Result<()> {
unsafe { self.setsockopt(libc::SOL_SOCKET, libc::SO_REUSEPORT, reuse as c_int) }
}
Expand Down