Recover from potentially but unlikely poisioned mutexes.

This commit is contained in:
projectmoon 2020-09-27 09:22:09 +00:00 committed by ProjectMoon
parent 620bea0521
commit f844b09213
1 changed files with 5 additions and 1 deletions

View File

@ -216,7 +216,11 @@ impl EventEmitter for DiceBot {
//Ignore messages that are older than configured duration. //Ignore messages that are older than configured duration.
if !check_message_age(event, get_oldest_message_age(&self.config)) { if !check_message_age(event, get_oldest_message_age(&self.config)) {
let mut state = self.state.lock().unwrap(); let mut state = match self.state.lock() {
Ok(state) => state,
Err(poisoned) => poisoned.into_inner(),
};
(*state).skipped_old_messages(); (*state).skipped_old_messages();
return; return;
} }