Skip to content

Commit

Permalink
Update components/salsa-2022/src/storage.rs
Browse files Browse the repository at this point in the history
  • Loading branch information
nikomatsakis authored Apr 2, 2024
1 parent 998bcf6 commit 9deaf3e
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion components/salsa-2022/src/storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,14 @@ where
loop {
self.runtime.set_cancellation_flag();

// jars need to be protected by a lock to avoid deadlocks.
// Acquire lock before we check if we have unique access to the jars.
// If we do not yet have unique access, we will go to sleep and wait for
// the snapshots to be dropped, which will signal the cond var associated
// with this lock.
//
// NB: We have to acquire the lock first to ensure that we can check for
// unique access and go to sleep waiting on the condvar atomically,
// as described in PR #474.
let mut guard = self.shared.noti_lock.lock();
// If we have unique access to the jars, we are done.
if Arc::get_mut(self.shared.jars.as_mut().unwrap()).is_some() {
Expand Down

0 comments on commit 9deaf3e

Please sign in to comment.