]> git.feebdaed.xyz Git - 0xmirror/tokio.git/commitdiff
fs: handle `EINTR` in `fs::write` for io-uring (#7786) master
authorvrtgs <vrtgs@vrtgs.xyz>
Wed, 24 Dec 2025 15:18:25 +0000 (18:18 +0300)
committerGitHub <noreply@github.com>
Wed, 24 Dec 2025 15:18:25 +0000 (23:18 +0800)
tokio/src/fs/write.rs

index c70a197881168612039ae8b93bb17d7f6354ce2d..76387134c8b19ffee7b092d2fe3a2b82409be5b9 100644 (file)
@@ -72,12 +72,14 @@ async fn write_uring(path: &Path, mut buf: OwnedBuf) -> io::Result<()> {
     let mut buf_offset: usize = 0;
     let mut file_offset: u64 = 0;
     while buf_offset < total {
-        let (n, _buf, _fd) = Op::write_at(fd, buf, buf_offset, file_offset)?.await;
-        // TODO: handle EINT here
-        let n = n?;
-        if n == 0 {
-            return Err(io::ErrorKind::WriteZero.into());
-        }
+        let (res, _buf, _fd) = Op::write_at(fd, buf, buf_offset, file_offset)?.await;
+
+        let n = match res {
+            Ok(0) => return Err(io::ErrorKind::WriteZero.into()),
+            Ok(n) => n,
+            Err(e) if e.kind() == io::ErrorKind::Interrupted => 0,
+            Err(e) => return Err(e),
+        };
 
         buf = _buf;
         fd = _fd;