Skip to content

Commit

Permalink
fix deadlock with single worker
Browse files Browse the repository at this point in the history
  • Loading branch information
agourlay committed Aug 21, 2022
1 parent decd6c6 commit 2077cc5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
15 changes: 7 additions & 8 deletions src/password_finder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,12 +230,11 @@ mod tests {
assert!(password.is_none());
}

// Takes too long on the CI
//#[test]
// fn find_four_letters_password() {
// let password = find_password_gen("test-files/4.test.txt.zip", 4)
// .unwrap()
// .unwrap();
// assert_eq!(password, "abcd");
// }
#[test]
fn find_four_letters_password() {
let password = find_password_gen("test-files/4.test.txt.zip", 4)
.unwrap()
.unwrap();
assert_eq!(password, "abcd");
}
}
2 changes: 1 addition & 1 deletion src/password_worker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ pub fn password_checker(
match zip.read_to_end(&mut buffer) {
Err(_) => (), // password collision - continue
Ok(_) => {
// Send password and continue processing while waiting for signal
send_password_found
.send(password)
.expect("Send found password should not fail");
break;
}
}
}
Expand Down

0 comments on commit 2077cc5

Please sign in to comment.