Skip to content

Commit 2f5f80a

Browse files
committed
handle EINT in tokio::fs::write for io-uring
1 parent 08f4065 commit 2f5f80a

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

tokio/src/fs/write.rs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,17 @@ async fn write_uring(path: &Path, mut buf: OwnedBuf) -> io::Result<()> {
7373
let mut file_offset: u64 = 0;
7474
while buf_offset < total {
7575
let (n, _buf, _fd) = Op::write_at(fd, buf, buf_offset, file_offset)?.await;
76-
// TODO: handle EINT here
77-
let n = n?;
78-
if n == 0 {
79-
return Err(io::ErrorKind::WriteZero.into());
80-
}
76+
77+
let is_eint = |err: &io::Error| {
78+
err.raw_os_error() == Some(libc::EINTR) || err.kind() == io::ErrorKind::Interrupted
79+
};
80+
81+
let n = match n {
82+
Ok(0) => return Err(io::ErrorKind::WriteZero.into()),
83+
Ok(n) => n,
84+
Err(e) if is_eint(&e) => 0,
85+
Err(e) => return Err(e),
86+
};
8187

8288
buf = _buf;
8389
fd = _fd;

0 commit comments

Comments
 (0)