diff --git a/connect/src/spirc.rs b/connect/src/spirc.rs index 9594082e..132c9fcd 100644 --- a/connect/src/spirc.rs +++ b/connect/src/spirc.rs @@ -333,7 +333,11 @@ impl Future for SpircTask { progress = true; self.handle_frame(frame); } - Async::Ready(None) => panic!("subscription terminated"), + Async::Ready(None) => { + error!("subscription terminated"); + self.shutdown = true; + self.commands.close(); + }, Async::NotReady => (), } diff --git a/src/main.rs b/src/main.rs index e2c5f51e..84b2fdd8 100644 --- a/src/main.rs +++ b/src/main.rs @@ -502,21 +502,20 @@ impl Future for Main { progress = true; } - let mut try_to_reconnect = false; + let mut drop_spirc_and_try_to_reconnect = false; if let Some(ref mut spirc_task) = self.spirc_task { if let Async::Ready(()) = spirc_task.poll().unwrap() { if self.shutdown { return Ok(Async::Ready(())); } else { warn!("Spirc shut down unexpectedly"); - self.spirc_task = None; - - try_to_reconnect = true; + drop_spirc_and_try_to_reconnect = true; } progress = true; } } - if try_to_reconnect { + if drop_spirc_and_try_to_reconnect { + self.spirc_task = None; while (!self.auto_connect_times.is_empty()) && ((Instant::now() - self.auto_connect_times[0]).as_secs() > 600) { let _ = self.auto_connect_times.remove(0); }