Skip to content

Commit

Permalink
Simplify Drop implementation for File
Browse files Browse the repository at this point in the history
Do not try to spawn new tasks as this sometimes
leads to deadlocks on 1-CPU machines, in particular VMs
and old Android phones.
  • Loading branch information
link2xt committed Jul 17, 2022
1 parent 798ce31 commit 5f1260f
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions src/fs/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ use crate::fs::{Metadata, Permissions};
use crate::future;
use crate::io::{self, Read, Seek, SeekFrom, Write};
use crate::path::Path;
use crate::prelude::*;
use crate::task::{spawn_blocking, Context, Poll, Waker};
use crate::utils::Context as _;

Expand Down Expand Up @@ -315,7 +314,7 @@ impl Drop for File {
// non-blocking fashion, but our only other option here is losing data remaining in the
// write cache. Good task schedulers should be resilient to occasional blocking hiccups in
// file destructors so we don't expect this to be a common problem in practice.
let _ = futures_lite::future::block_on(self.flush());
(&*self.file).flush().ok();
}
}

Expand Down

0 comments on commit 5f1260f

Please sign in to comment.