From 5f1260f8d2dec825aab600e74a80fba45c7eba67 Mon Sep 17 00:00:00 2001 From: link2xt Date: Sun, 17 Jul 2022 12:17:06 +0000 Subject: [PATCH] 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. --- src/fs/file.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/fs/file.rs b/src/fs/file.rs index 9a4ab77b4..bfe8f0b93 100644 --- a/src/fs/file.rs +++ b/src/fs/file.rs @@ -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(); } }