Skip to content

Commit

Permalink
handle the mutex error
Browse files Browse the repository at this point in the history
  • Loading branch information
TimothyYe committed Mar 1, 2024
1 parent 2939da4 commit 675ff3c
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions src/sequence/port_sequence.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,25 @@ impl SequenceDetector for PortSequenceDetector {
thread::spawn(move || loop {
thread::sleep(std::time::Duration::from_millis(200));

let mut client_sequences = client_sequences.lock().unwrap();
let mut client_timeout = client_timeout.lock().unwrap();
let client_sequences_guard = match client_sequences.lock() {
Ok(guard) => guard,
Err(poisoned) => {
println!("Error: {:?}", poisoned);
continue;
}
};

let client_timeout_guard = match client_timeout.lock() {
Ok(guard) => guard,
Err(poisoned) => {
println!("Error: {:?}", poisoned);
continue;
}
};

let mut client_sequences = client_sequences_guard;
let mut client_timeout = client_timeout_guard;

let now = SystemTime::now()
.duration_since(UNIX_EPOCH)
.unwrap()
Expand Down

0 comments on commit 675ff3c

Please sign in to comment.