Skip to content

Commit 8c00cc5

Browse files
author
Stjepan Glavina
committed
Flush more often to prevent flushes during seek
1 parent 8d3d80a commit 8c00cc5

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/fs/file.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -144,10 +144,10 @@ impl File {
144144
/// # Ok(()) }) }
145145
/// ```
146146
pub async fn sync_all(&self) -> io::Result<()> {
147-
// Drain the write cache before calling `sync_all()`.
147+
// Flush the write cache before calling `sync_all()`.
148148
let state = future::poll_fn(|cx| {
149149
let state = futures_core::ready!(self.lock.poll_lock(cx));
150-
state.poll_drain(cx)
150+
state.poll_flush(cx)
151151
})
152152
.await?;
153153

@@ -214,11 +214,11 @@ impl File {
214214
/// # Ok(()) }) }
215215
/// ```
216216
pub async fn set_len(&self, size: u64) -> io::Result<()> {
217-
// Invalidate the read/write cache before calling `set_len()`.
217+
// Invalidate the read cache and flush the write cache before calling `set_len()`.
218218
let state = future::poll_fn(|cx| {
219219
let state = futures_core::ready!(self.lock.poll_lock(cx));
220220
let state = futures_core::ready!(state.poll_unread(cx))?;
221-
state.poll_drain(cx)
221+
state.poll_flush(cx)
222222
})
223223
.await?;
224224

@@ -604,9 +604,9 @@ impl LockGuard<State> {
604604
return Poll::Ready((&*self.file).seek(pos));
605605
}
606606

607-
// Invalidate the read/write cache before calling `seek()`.
607+
// Invalidate the read cache and flush the write cache before calling `seek()`.
608608
self = futures_core::ready!(self.poll_unread(cx))?;
609-
self = futures_core::ready!(self.poll_drain(cx))?;
609+
self = futures_core::ready!(self.poll_flush(cx))?;
610610

611611
// Seek to the new position. This call is hopefully not blocking because it should just
612612
// change the internal offset into the file and not touch the actual file.
@@ -641,8 +641,8 @@ impl LockGuard<State> {
641641
}
642642
}
643643
Mode::Writing => {
644-
// If we're in writing mode, drain the write cache.
645-
self = futures_core::ready!(self.poll_drain(cx))?;
644+
// If we're in writing mode, flush the write cache.
645+
self = futures_core::ready!(self.poll_flush(cx))?;
646646
}
647647
}
648648

0 commit comments

Comments
 (0)