Skip to content

Commit

Permalink
fixup! File: Try doing a non-blocking read before punting to the thre…
Browse files Browse the repository at this point in the history
…adpool
  • Loading branch information
wmanley committed Mar 21, 2021
1 parent 9972b59 commit 23a3c31
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions tokio/src/fs/file.rs
Expand Up @@ -491,18 +491,18 @@ impl AsyncRead for File {
loop {
match inner.state {
Idle(ref mut buf_cell) => {
let mut buf = buf_cell.take().unwrap();
let buf = buf_cell.as_mut().unwrap();

if !buf.is_empty() {
buf.copy_to(dst);
*buf_cell = Some(buf);
return Ready(Ok(()));
}

if let Some(x) = read_nowait::try_nonblocking_read(me.std.as_ref(), dst) {
return Ready(x);
}

let mut buf = buf_cell.take().unwrap();
buf.ensure_capacity_for(dst);
let std = me.std.clone();

Expand Down

0 comments on commit 23a3c31

Please sign in to comment.