2
0
Fork 1
mirror of https://github.com/async-rs/async-std.git synced 2025-02-28 07:09:40 +00:00
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 <stjepang@gmail.com>
This commit is contained in:
bors[bot] 2019-09-08 22:34:38 +00:00 committed by GitHub
commit b849669998
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -419,7 +419,11 @@ cfg_if! {
impl IntoRawFd for File {
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 {
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()
}
}
}