mirror of
https://github.com/tokio-rs/tokio.git
synced 2025-09-25 12:00:35 +00:00
fs: wait for in-flight ops before cloning File
(#5803)
If there is an ongoing operation on a file, wait for that to complete before performing the clone in `File::try_clone`. This avoids a race between the ongoing operation and any subsequent operations performed on the clone. Fixes: #5759
This commit is contained in:
parent
910a1e2fcf
commit
6b076a2743
@ -399,6 +399,7 @@ impl File {
|
||||
/// # }
|
||||
/// ```
|
||||
pub async fn try_clone(&self) -> io::Result<File> {
|
||||
self.inner.lock().await.complete_inflight().await;
|
||||
let std = self.std.clone();
|
||||
let std_file = asyncify(move || std.try_clone()).await?;
|
||||
Ok(File::from_std(std_file))
|
||||
|
Loading…
x
Reference in New Issue
Block a user