mirror of
https://github.com/async-rs/async-std.git
synced 2025-02-06 12:45:32 +00:00
Simplify Drop implementation for File
Do not try to spawn new tasks as this sometimes leads to deadlocks on 1-CPU machines, in particular VMs and old Android phones.
This commit is contained in:
parent
798ce31e10
commit
fe7a343d3b
1 changed files with 2 additions and 2 deletions
|
@ -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 _;
|
||||
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -883,6 +882,7 @@ impl LockGuard<State> {
|
|||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::prelude::*;
|
||||
|
||||
#[test]
|
||||
fn async_file_drop() {
|
||||
|
|
Loading…
Reference in a new issue