about summary refs log tree commit diff
path: root/library/std/src/sys/net/connection/socket/unix.rs
diff options
context:
space:
mode:
authorGuillaume Gomez <guillaume1.gomez@gmail.com>2025-06-24 11:20:05 +0200
committerGitHub <noreply@github.com>2025-06-24 11:20:05 +0200
commit24cd817cfa1e63242a6936c8faf64a47085ecf83 (patch)
tree5e728954acbe21301fc69ce1537fe722ea7ca92e /library/std/src/sys/net/connection/socket/unix.rs
parent99b18d6c5062449db8e7ccded4cb69b555a239c3 (diff)
parent426ab142507fca8704d934da556f1c96b0fd61b2 (diff)
downloadrust-24cd817cfa1e63242a6936c8faf64a47085ecf83.tar.gz
rust-24cd817cfa1e63242a6936c8faf64a47085ecf83.zip
Rollup merge of #140005 - mlowicki:patch-1, r=tgross35
Set MSG_NOSIGNAL for UnixStream

https://github.com/rust-lang/rust/issues/139956

Same logic as for https://github.com/rust-lang/rust/blob/1f76d219c906f0112bb1872f33aa977164c53fa6/library/std/src/sys/net/connection/socket.rs#L399-L405.
Diffstat (limited to 'library/std/src/sys/net/connection/socket/unix.rs')
-rw-r--r--library/std/src/sys/net/connection/socket/unix.rs8
1 files changed, 8 insertions, 0 deletions
diff --git a/library/std/src/sys/net/connection/socket/unix.rs b/library/std/src/sys/net/connection/socket/unix.rs
index b35d5d2aa84..b2a4961c3c5 100644
--- a/library/std/src/sys/net/connection/socket/unix.rs
+++ b/library/std/src/sys/net/connection/socket/unix.rs
@@ -281,6 +281,14 @@ impl Socket {
         self.0.duplicate().map(Socket)
     }
 
+    pub fn send_with_flags(&self, buf: &[u8], flags: c_int) -> io::Result<usize> {
+        let len = cmp::min(buf.len(), <wrlen_t>::MAX as usize) as wrlen_t;
+        let ret = cvt(unsafe {
+            libc::send(self.as_raw_fd(), buf.as_ptr() as *const c_void, len, flags)
+        })?;
+        Ok(ret as usize)
+    }
+
     fn recv_with_flags(&self, mut buf: BorrowedCursor<'_>, flags: c_int) -> io::Result<()> {
         let ret = cvt(unsafe {
             libc::recv(