crypto: False alarm with the deadlock we just didn't use the right method.

This commit is contained in:
Damir Jelić 2020-08-10 16:18:20 +02:00
parent 18b655f829
commit d7bcf42a2b

View file

@ -86,9 +86,8 @@ impl VerificationMachine {
} }
pub fn garbage_collect(&self) { pub fn garbage_collect(&self) {
// TODO this seems to have a deadlock. self.verifications
// self.verifications .retain(|_, s| !(s.is_done() || s.is_canceled()));
// .retain(|_, s| !(s.is_canceled() || s.is_done()));
for sas in self.verifications.iter() { for sas in self.verifications.iter() {
if let Some(r) = sas.cancel_if_timed_out() { if let Some(r) = sas.cancel_if_timed_out() {
@ -248,7 +247,7 @@ mod test {
async fn full_flow() { async fn full_flow() {
let (alice_machine, bob) = setup_verification_machine().await; let (alice_machine, bob) = setup_verification_machine().await;
let alice = alice_machine.verifications.get(bob.flow_id()).unwrap(); let alice = alice_machine.get_sas(bob.flow_id()).unwrap();
let mut event = alice let mut event = alice
.accept() .accept()
@ -303,7 +302,7 @@ mod test {
#[tokio::test] #[tokio::test]
async fn timing_out() { async fn timing_out() {
let (alice_machine, bob) = setup_verification_machine().await; let (alice_machine, bob) = setup_verification_machine().await;
let alice = alice_machine.verifications.get(bob.flow_id()).unwrap(); let alice = alice_machine.get_sas(bob.flow_id()).unwrap();
assert!(!alice.timed_out()); assert!(!alice.timed_out());
assert!(alice_machine.outgoing_to_device_messages.is_empty()); assert!(alice_machine.outgoing_to_device_messages.is_empty());
@ -317,5 +316,7 @@ mod test {
assert!(alice_machine.outgoing_to_device_messages.is_empty()); assert!(alice_machine.outgoing_to_device_messages.is_empty());
alice_machine.garbage_collect(); alice_machine.garbage_collect();
assert!(!alice_machine.outgoing_to_device_messages.is_empty()); assert!(!alice_machine.outgoing_to_device_messages.is_empty());
alice_machine.garbage_collect();
assert!(alice_machine.verifications.is_empty());
} }
} }