fix(sync/wait_condition): deadlock in WaitCondition::wait

Instead of using a simple switch to determine if preemption is enabled
(`is_preemptable: bool`), a counter is used instead. This handles the
case where a function holding a `PreemptGuard` calls another function
that creates a new `PreemptGuard`.

Signed-off-by: Anhad Singh <andypython@protonmail.com>
This commit is contained in:
Anhad Singh
2025-12-15 13:05:29 +11:00
parent 62a572a0f0
commit d9eae6bb75
4 changed files with 20 additions and 8 deletions
+1 -1
View File
@@ -165,7 +165,7 @@ pub fn switch(token: &mut CleanLockToken) -> SwitchResult {
// We are careful not to lock this context twice
let prev_context_guard = unsafe { prev_context_lock.write_arc() };
if !prev_context_guard.is_preemptable {
if !prev_context_guard.is_preemptable() {
return SwitchResult::AllContextsIdle;
}