From d579665bd1e1649c9597cdaf3da3c2ca7f54e793 Mon Sep 17 00:00:00 2001 From: Chris Denton Date: Thu, 28 Apr 2022 18:46:33 +0100 Subject: [PATCH] Yield the thread when waiting to delete a file --- library/std/src/sys/windows/fs.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/library/std/src/sys/windows/fs.rs b/library/std/src/sys/windows/fs.rs index e6f0f0f30239..5e055307c291 100644 --- a/library/std/src/sys/windows/fs.rs +++ b/library/std/src/sys/windows/fs.rs @@ -14,6 +14,7 @@ use crate::sys::handle::Handle; use crate::sys::time::SystemTime; use crate::sys::{c, cvt}; use crate::sys_common::{AsInner, FromInner, IntoInner}; +use crate::thread; use super::path::maybe_verbatim; use super::to_u16s; @@ -1059,6 +1060,7 @@ fn remove_dir_all_iterative(f: &File, delete: fn(&File) -> io::Result<()>) -> io // Otherwise return the error. Err(e) => return Err(e), } + thread::yield_now(); } } } @@ -1072,6 +1074,7 @@ fn remove_dir_all_iterative(f: &File, delete: fn(&File) -> io::Result<()>) -> io if i == MAX_RETRIES || e.kind() != io::ErrorKind::DirectoryNotEmpty { return Err(e); } + thread::yield_now(); } else { break; }