Rollup merge of #114696 - g0djan:godjan/fix_114610, r=Mark-Simulacrum

Fix a pthread_t handle leak #114610

https://github.com/rust-lang/rust/issues/114610

Ran the tests as described in https://github.com/rust-lang/rust/blob/master/src/doc/rustc/src/platform-support/wasm32-wasi-preview1-threads.md?plain=1#L125
This commit is contained in:
Guillaume Gomez 2023-08-23 17:46:33 +02:00 committed by GitHub
commit 128ff0897b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -47,12 +47,20 @@ pub fn pthread_attr_setstacksize(
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;
}
}
pub struct Thread {
id: libc::pthread_t,
}
impl Drop for Thread {
fn drop(&mut self) {
let ret = unsafe { libc::pthread_detach(self.id) };
debug_assert_eq!(ret, 0);
}
}
} else {
pub struct Thread(!);
}