From 66d5b6e68ae02521485af9cc96e1def3fd4e011a Mon Sep 17 00:00:00 2001 From: Pat Hickey Date: Fri, 1 Sep 2023 09:54:27 -0700 Subject: [PATCH] background task handles ewouldblock as well --- crates/wasi/src/preview2/tcp.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/crates/wasi/src/preview2/tcp.rs b/crates/wasi/src/preview2/tcp.rs index d1117cf8e555..af245a6f9e3c 100644 --- a/crates/wasi/src/preview2/tcp.rs +++ b/crates/wasi/src/preview2/tcp.rs @@ -143,8 +143,13 @@ impl TcpWriteStream { // to flush. while !bytes.is_empty() { stream.writable().await?; - let n = stream.try_write(&bytes)?; - let _ = bytes.split_to(n); + match stream.try_write(&bytes) { + Ok(n) => { + let _ = bytes.split_to(n); + } + Err(e) if e.kind() == std::io::ErrorKind::WouldBlock => continue, + Err(e) => return Err(OutputStreamError::LastOperationFailed(e.into())), + } } Ok(())