Fix a pthread_t handle leak #114610
This commit is contained in:
parent
60713f4234
commit
42a708083a
1 changed files with 12 additions and 0 deletions
|
@ -47,6 +47,7 @@ cfg_if::cfg_if! {
|
|||
stack_size: libc::size_t,
|
||||
) -> ffi::c_int;
|
||||
pub fn pthread_attr_destroy(attr: *mut pthread_attr_t) -> ffi::c_int;
|
||||
pub fn pthread_detach(thread: pthread_t) -> ffi::c_int;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -178,6 +179,17 @@ impl Thread {
|
|||
}
|
||||
}
|
||||
|
||||
cfg_if::cfg_if! {
|
||||
if #[cfg(target_feature = "atomics")] {
|
||||
impl Drop for Thread {
|
||||
fn drop(&mut self) {
|
||||
let ret = unsafe { libc::pthread_detach(self.id) };
|
||||
debug_assert_eq!(ret, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn available_parallelism() -> io::Result<NonZeroUsize> {
|
||||
unsupported()
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue