Skip to content

Commit b849669

Browse files
bors[bot]Stjepan Glavina
and
Stjepan Glavina
authored
Merge #165
165: Fix a bug in conversion of File into raw handle r=stjepang a=stjepang Same bugfix as #148, but applied to `async_std::fs::File`. Co-authored-by: Stjepan Glavina <[email protected]>
2 parents 7c05356 + 41f345d commit b849669

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

Diff for: src/fs/file.rs

+10-2
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,11 @@ cfg_if! {
419419

420420
impl IntoRawFd for File {
421421
fn into_raw_fd(self) -> RawFd {
422-
self.file.as_raw_fd()
422+
let file = self.file.clone();
423+
drop(self);
424+
Arc::try_unwrap(file)
425+
.expect("cannot acquire ownership of file handle after drop")
426+
.into_raw_fd()
423427
}
424428
}
425429
}
@@ -442,7 +446,11 @@ cfg_if! {
442446

443447
impl IntoRawHandle for File {
444448
fn into_raw_handle(self) -> RawHandle {
445-
self.file.as_raw_handle()
449+
let file = self.file.clone();
450+
drop(self);
451+
Arc::try_unwrap(file)
452+
.expect("cannot acquire ownership of file's handle after drop")
453+
.into_raw_handle()
446454
}
447455
}
448456
}

0 commit comments

Comments
 (0)