Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 5f1260f

Browse files
committed
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.
1 parent 798ce31 commit 5f1260f

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

src/fs/file.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ use crate::fs::{Metadata, Permissions};
1111
use crate::future;
1212
use crate::io::{self, Read, Seek, SeekFrom, Write};
1313
use crate::path::Path;
14-
use crate::prelude::*;
1514
use crate::task::{spawn_blocking, Context, Poll, Waker};
1615
use crate::utils::Context as _;
1716

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

0 commit comments

Comments
 (0)