about summary refs log tree commit diff
path: root/library
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2022-11-30 07:59:24 +0000
committerbors <bors@rust-lang.org>2022-11-30 07:59:24 +0000
commita569a88f5500e8780c7cc65fa53fc8b098517674 (patch)
tree84e4810c4251b35623e3f984a6d87ea72ce6a47a /library
parent8de4b138455add55bde6de5553a933a2ab79b71f (diff)
parent815b6e5ab83b2c033eed26648ec554a08c65b268 (diff)
downloadrust-a569a88f5500e8780c7cc65fa53fc8b098517674.tar.gz
rust-a569a88f5500e8780c7cc65fa53fc8b098517674.zip
Auto merge of #105080 - matthiaskrgr:rollup-7ffj4oe, r=matthiaskrgr
Rollup of 5 pull requests

Successful merges:

 - #104697 (Restore control flow on error in EUV)
 - #104811 (feat: implement TcpStream shutdown for wasm32-wasi)
 - #105039 (Fix an ICE parsing a malformed literal in `concat_bytes!`.)
 - #105071 (Add Nicholas Nethercote to `.mailmap`.)
 - #105079 (Add bots to `.mailmap`)

Failed merges:

 - #105074 (Add Nicholas Bishop to `.mailmap`)

r? `@ghost`
`@rustbot` modify labels: rollup
Diffstat (limited to 'library')
-rw-r--r--library/std/src/sys/wasi/net.rs10
1 files changed, 8 insertions, 2 deletions
diff --git a/library/std/src/sys/wasi/net.rs b/library/std/src/sys/wasi/net.rs
index 590d268c380..cf4ebba1a39 100644
--- a/library/std/src/sys/wasi/net.rs
+++ b/library/std/src/sys/wasi/net.rs
@@ -119,8 +119,14 @@ impl TcpStream {
         unsupported()
     }
 
-    pub fn shutdown(&self, _: Shutdown) -> io::Result<()> {
-        unsupported()
+    pub fn shutdown(&self, how: Shutdown) -> io::Result<()> {
+        let wasi_how = match how {
+            Shutdown::Read => wasi::SDFLAGS_RD,
+            Shutdown::Write => wasi::SDFLAGS_WR,
+            Shutdown::Both => wasi::SDFLAGS_RD | wasi::SDFLAGS_WR,
+        };
+
+        unsafe { wasi::sock_shutdown(self.socket().as_raw_fd() as _, wasi_how).map_err(err2io) }
     }
 
     pub fn duplicate(&self) -> io::Result<TcpStream> {