From 24d8da69c0a38dc9ea9f679e1d40ffd3bc27f5b7 Mon Sep 17 00:00:00 2001 From: Kyle Simpson Date: Sat, 10 Apr 2021 22:44:17 +0100 Subject: [PATCH] Driver: Fix crash on `.leave()` (#63) Leaving (rather than removing) a call would cause the driver to crash as it would try to use a non-existent connection immediately after it had been invalidated. This has been tested using a modified `examples/serenity/voice_storage`, felyne, and via `cargo make ready`. --- src/driver/tasks/mixer.rs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/driver/tasks/mixer.rs b/src/driver/tasks/mixer.rs index 331aa8a50..61f43926d 100644 --- a/src/driver/tasks/mixer.rs +++ b/src/driver/tasks/mixer.rs @@ -132,11 +132,14 @@ impl Mixer { }; } - if let Err(e) = self.cycle().and_then(|_| self.audio_commands_events()) { - events_failure |= e.should_trigger_interconnect_rebuild(); - conn_failure |= e.should_trigger_connect(); + // The above action may have invalidated the connection; need to re-check! + if self.conn_active.is_some() { + if let Err(e) = self.cycle().and_then(|_| self.audio_commands_events()) { + events_failure |= e.should_trigger_interconnect_rebuild(); + conn_failure |= e.should_trigger_connect(); - debug!("Mixer thread cycle: {:?}", e); + debug!("Mixer thread cycle: {:?}", e); + } } } else { match self.mix_rx.recv() {