diff options
| author | David Carlier <devnexen@gmail.com> | 2022-07-06 20:01:25 +0100 |
|---|---|---|
| committer | David Carlier <devnexen@gmail.com> | 2022-07-06 20:05:39 +0100 |
| commit | 10f5a19a4deac4a7300ed6bfad11731d451713b0 (patch) | |
| tree | e8b3a4133af4a0b5d73d6edf9ff40208f50cbbb4 /library/std/src/sys/unix/net.rs | |
| parent | 48ef00e36f58c1debaec8d5612297b8819f7a690 (diff) | |
| download | rust-10f5a19a4deac4a7300ed6bfad11731d451713b0.tar.gz rust-10f5a19a4deac4a7300ed6bfad11731d451713b0.zip | |
changes from feedback
Diffstat (limited to 'library/std/src/sys/unix/net.rs')
| -rw-r--r-- | library/std/src/sys/unix/net.rs | 20 |
1 files changed, 8 insertions, 12 deletions
diff --git a/library/std/src/sys/unix/net.rs b/library/std/src/sys/unix/net.rs index 30667edafba..c942689eddf 100644 --- a/library/std/src/sys/unix/net.rs +++ b/library/std/src/sys/unix/net.rs @@ -427,19 +427,15 @@ impl Socket { self.0.set_nonblocking(nonblocking) } - #[cfg(target_os = "linux")] + #[cfg(any(target_os = "linux", target_os = "freebsd", target_os = "openbsd"))] pub fn set_mark(&self, mark: u32) -> io::Result<()> { - setsockopt(self, libc::SOL_SOCKET, libc::SO_MARK, mark as libc::c_int) - } - - #[cfg(target_os = "freebsd")] - pub fn set_mark(&self, mark: u32) -> io::Result<()> { - setsockopt(self, libc::SOL_SOCKET, libc::SO_USER_COOKIE, mark) - } - - #[cfg(target_os = "openbsd")] - pub fn set_mark(&self, mark: u32) -> io::Result<()> { - setsockopt(self, libc::SOL_SOCKET, libc::SO_RTABLE, mark as libc::c_int) + #[cfg(target_os = "linux")] + let option = libc::SO_MARK; + #[cfg(target_os = "freebsd")] + let option = libc::SO_USER_COOKIE; + #[cfg(target_os = "openbsd")] + let option = libc::SO_RTABLE; + setsockopt(self, libc::SOL_SOCKET, option, mark as libc::c_int) } pub fn take_error(&self) -> io::Result<Option<io::Error>> { |
