Skip to content

Commit 9d6b67f

Browse files
committed
feat: immediately release the lock when there are no more holders
Signed-off-by: Benjamin Bouvier <[email protected]>
1 parent f3ee9eb commit 9d6b67f

File tree

1 file changed

+8
-0
lines changed
  • crates/matrix-sdk-crypto/src/store

1 file changed

+8
-0
lines changed

crates/matrix-sdk-crypto/src/store/locks.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,14 @@ impl CryptoStoreLock {
186186
// If there are no more users, we can quit.
187187
if this.num_holders.load(atomic::Ordering::SeqCst) == 0 {
188188
tracing::info!("exiting the lease extension loop");
189+
190+
// Cancel the lease with another 0ms lease.
191+
// If we don't get the lock, that's (weird but) fine.
192+
let _ = this
193+
.store
194+
.try_take_leased_lock(0, &this.lock_key, &this.lock_holder)
195+
.await;
196+
189197
// Exit the loop.
190198
break;
191199
}

0 commit comments

Comments
 (0)