mirror of
https://github.com/librespot-org/librespot.git
synced 2024-12-18 17:11:53 +00:00
Convert another panic to error handling.
Compatibility fix for Rust 1.33.
This commit is contained in:
parent
0e22678a28
commit
a52092e094
2 changed files with 9 additions and 6 deletions
|
@ -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 => (),
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue