From 517326bb2b63b6f6ddcf5deec7a283ee510f44df Mon Sep 17 00:00:00 2001 From: Mahdi Rakhshandehroo <24380301+mrakh@users.noreply.github.com> Date: Mon, 27 Feb 2023 00:15:09 +0000 Subject: [PATCH] Use Send-safe wrapper in install_trigger function When targeting musl, libc::pthread_t aliases to *mut c_void, which is not Send, and therefore causes compilation failures. pthread_t is meant to be an opaque handle, so we can safely just wrap it in a newtype that explicitly implements Send. --- glommio/src/executor/stall.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/glommio/src/executor/stall.rs b/glommio/src/executor/stall.rs index 46f433e45..55461356d 100644 --- a/glommio/src/executor/stall.rs +++ b/glommio/src/executor/stall.rs @@ -162,13 +162,15 @@ impl StallDetector { timer: Arc, signal: i32, ) -> JoinHandle<()> { - let tid = unsafe { nix::libc::pthread_self() }; + struct SendWrapper(libc::pthread_t); + unsafe impl Send for SendWrapper {} + let tid = SendWrapper(unsafe { nix::libc::pthread_self() }); std::thread::spawn(enclose::enclose! { (terminated, timer) move || { while timer.wait().is_ok() { if terminated.load(Ordering::Relaxed) { return } - unsafe { nix::libc::pthread_kill(tid, signal) }; + unsafe { nix::libc::pthread_kill(tid.0, signal) }; } }}) }