diff options
| author | bors <bors@rust-lang.org> | 2022-08-29 05:12:53 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2022-08-29 05:12:53 +0000 |
| commit | 94b2b15e63c5d2b2a6a0910e3dae554ce9415bf9 (patch) | |
| tree | 52fe4cbdebc7c7b04dcd6a25793b8a8660969700 /library/std/src/sys | |
| parent | 7c142a61373eda083cec64de383cf79e9a173f16 (diff) | |
| parent | fa177a9db2d7c96ced985d018a0108de033f5ded (diff) | |
Auto merge of #101143 - matthiaskrgr:rollup-g8y5k0g, r=matthiaskrgr
Rollup of 9 pull requests Successful merges: - #94890 (Support parsing IP addresses from a byte string) - #96334 (socket `set_mark` addition.) - #99027 (Replace `Body::basic_blocks()` with field access) - #100437 (Improve const mismatch `FulfillmentError`) - #100843 (Migrate part of rustc_infer to session diagnostic) - #100897 (extra sanity check against consts pointing to mutable memory) - #100959 (translations: rename warn_ to warning) - #101111 (Use the declaration's SourceInfo for FnEntry retags, not the outermost) - #101116 ([rustdoc] Remove Attrs type alias) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Diffstat (limited to 'library/std/src/sys')
| -rw-r--r-- | library/std/src/sys/unix/net.rs | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/library/std/src/sys/unix/net.rs b/library/std/src/sys/unix/net.rs index 85dcfc747af..b84bf8f9264 100644 --- a/library/std/src/sys/unix/net.rs +++ b/library/std/src/sys/unix/net.rs @@ -438,6 +438,17 @@ impl Socket { self.0.set_nonblocking(nonblocking) } + #[cfg(any(target_os = "linux", target_os = "freebsd", target_os = "openbsd"))] + pub fn set_mark(&self, mark: u32) -> io::Result<()> { + #[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>> { let raw: c_int = getsockopt(self, libc::SOL_SOCKET, libc::SO_ERROR)?; if raw == 0 { Ok(None) } else { Ok(Some(io::Error::from_raw_os_error(raw as i32))) } |
