forked from mirror/async-std
Fix a bug in conversion of File into raw handle
This commit is contained in:
parent
9bf06ce52b
commit
41f345d319
1 changed files with 10 additions and 2 deletions
|
@ -419,7 +419,11 @@ cfg_if! {
|
||||||
|
|
||||||
impl IntoRawFd for File {
|
impl IntoRawFd for File {
|
||||||
fn into_raw_fd(self) -> RawFd {
|
fn into_raw_fd(self) -> RawFd {
|
||||||
self.file.as_raw_fd()
|
let file = self.file.clone();
|
||||||
|
drop(self);
|
||||||
|
Arc::try_unwrap(file)
|
||||||
|
.expect("cannot acquire ownership of file handle after drop")
|
||||||
|
.into_raw_fd()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -442,7 +446,11 @@ cfg_if! {
|
||||||
|
|
||||||
impl IntoRawHandle for File {
|
impl IntoRawHandle for File {
|
||||||
fn into_raw_handle(self) -> RawHandle {
|
fn into_raw_handle(self) -> RawHandle {
|
||||||
self.file.as_raw_handle()
|
let file = self.file.clone();
|
||||||
|
drop(self);
|
||||||
|
Arc::try_unwrap(file)
|
||||||
|
.expect("cannot acquire ownership of file's handle after drop")
|
||||||
|
.into_raw_handle()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue