Skip to content

Commit f6d7984

Browse files
committed
test(core): check for the absence of deadlocks
1 parent 84f9155 commit f6d7984

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/core/rbtree/tests.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -546,6 +546,23 @@ fn qc_rbtree_interval_rw_lock_core(cmds: Vec<u8>) {
546546
log::trace!("{:?}", reference_rwlock);
547547
}
548548

549+
// Release completed locks. This will unblock and complete other locks
550+
// in turn. After repeating this step, if there are still incomplete
551+
// locks, that means our interval lock is prone to deadlocks.
552+
while !locks.is_empty() {
553+
let i = locks
554+
.iter()
555+
.cloned()
556+
.position(|id| subject_rwlock.is_complete(id));
557+
558+
if let Some(i) = i {
559+
let id = locks.swap_remove(i);
560+
subject_rwlock.unlock(id);
561+
} else {
562+
panic!("deadlock");
563+
}
564+
}
565+
549566
None
550567
})();
551568
}

0 commit comments

Comments
 (0)