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;
|
progress = true;
|
||||||
self.handle_frame(frame);
|
self.handle_frame(frame);
|
||||||
}
|
}
|
||||||
Async::Ready(None) => panic!("subscription terminated"),
|
Async::Ready(None) => {
|
||||||
|
error!("subscription terminated");
|
||||||
|
self.shutdown = true;
|
||||||
|
self.commands.close();
|
||||||
|
},
|
||||||
Async::NotReady => (),
|
Async::NotReady => (),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -502,21 +502,20 @@ impl Future for Main {
|
||||||
progress = true;
|
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 Some(ref mut spirc_task) = self.spirc_task {
|
||||||
if let Async::Ready(()) = spirc_task.poll().unwrap() {
|
if let Async::Ready(()) = spirc_task.poll().unwrap() {
|
||||||
if self.shutdown {
|
if self.shutdown {
|
||||||
return Ok(Async::Ready(()));
|
return Ok(Async::Ready(()));
|
||||||
} else {
|
} else {
|
||||||
warn!("Spirc shut down unexpectedly");
|
warn!("Spirc shut down unexpectedly");
|
||||||
self.spirc_task = None;
|
drop_spirc_and_try_to_reconnect = true;
|
||||||
|
|
||||||
try_to_reconnect = true;
|
|
||||||
}
|
}
|
||||||
progress = 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) {
|
while (!self.auto_connect_times.is_empty()) && ((Instant::now() - self.auto_connect_times[0]).as_secs() > 600) {
|
||||||
let _ = self.auto_connect_times.remove(0);
|
let _ = self.auto_connect_times.remove(0);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue