From b0d0dfb358fe01752cb1ad263d1cc567396b5dec Mon Sep 17 00:00:00 2001 From: sxyazi Date: Fri, 29 May 2026 14:32:48 +0800 Subject: [PATCH] Consider errors on next_line() --- yazi-dds/src/client.rs | 4 ++-- yazi-dds/src/stream.rs | 19 ++++++++++++++----- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/yazi-dds/src/client.rs b/yazi-dds/src/client.rs index e193e215..919af9fd 100644 --- a/yazi-dds/src/client.rs +++ b/yazi-dds/src/client.rs @@ -48,8 +48,8 @@ impl Client { writer.write_all(payload.as_bytes()).await.ok(); // Retry once } } - Ok(next) = lines.next_line() => { - let Some(line) = next else { + next = lines.next_line() => { + let Ok(Some(line)) = next else { (lines, writer) = Self::reconnect(&mut server).await; continue; }; diff --git a/yazi-dds/src/stream.rs b/yazi-dds/src/stream.rs index b092022b..5aba44bd 100644 --- a/yazi-dds/src/stream.rs +++ b/yazi-dds/src/stream.rs @@ -48,9 +48,12 @@ impl Stream { #[cfg(windows)] pub(super) async fn bind() -> io::Result { let p = Self::socket_file().await?; - Local::regular(&p).remove_file().await.ok(); - Ok(WinUnixListener(uds_windows::UnixListener::bind(p)?)) + + let listener = uds_windows::UnixListener::bind(p)?; + listener.set_nonblocking(true)?; + + Ok(WinUnixListener(listener)) } async fn socket_file() -> io::Result<&'static PathBuf> { @@ -75,9 +78,15 @@ impl WinUnixListener { pub(super) async fn accept( &self, ) -> io::Result<(tokio::net::TcpStream, uds_windows::SocketAddr)> { - let listener = self.0.try_clone()?; - let (stream, addr) = tokio::task::spawn_blocking(move || listener.accept()).await??; - Ok((Self::into_tokio(stream)?, addr)) + loop { + match self.0.accept() { + Ok((stream, addr)) => return Ok((Self::into_tokio(stream)?, addr)), + Err(e) if e.kind() == io::ErrorKind::WouldBlock => { + tokio::time::sleep(std::time::Duration::from_millis(20)).await; + } + Err(e) => return Err(e), + } + } } fn into_tokio(uds: uds_windows::UnixStream) -> io::Result {