Drop the MutexGuard of semaphore earlier

This commit is contained in:
Yuke Peng 2024-08-25 15:37:26 +08:00 committed by Tate, Hongliang Tian
parent 547e6430ee
commit ccdf2dc54f

View File

@ -198,6 +198,7 @@ impl Semaphore {
} else if zero_condition { } else if zero_condition {
return Ok(()); return Ok(());
} }
drop(val);
// Need to wait for the semaphore // Need to wait for the semaphore
if flags.contains(IpcFlags::IPC_NOWAIT) { if flags.contains(IpcFlags::IPC_NOWAIT) {
@ -219,7 +220,6 @@ impl Semaphore {
} else { } else {
self.pending_alters.lock().push_back(pending_op); self.pending_alters.lock().push_back(pending_op);
} }
drop(val);
// Wait // Wait
if let Some(timeout) = timeout { if let Some(timeout) = timeout {