Prevent librespot from panicking if server connection is lost.

This commit is contained in:
Konstantin Seiler 2020-01-22 21:55:45 +11:00
parent 362106df62
commit b6c676ad60
2 changed files with 9 additions and 3 deletions

View file

@ -283,13 +283,18 @@ where
loop {
let (cmd, data) = match self.0.poll() {
Ok(Async::Ready(t)) => t,
Ok(Async::Ready(Some(t))) => t,
Ok(Async::Ready(None)) => {
warn!("Connection to server closed.");
session.shutdown();
return Ok(Async::Ready(()));
},
Ok(Async::NotReady) => return Ok(Async::NotReady),
Err(e) => {
session.shutdown();
return Err(From::from(e));
}
}.expect("connection closed");
};
session.dispatch(cmd, data);
}

View file

@ -500,7 +500,8 @@ impl Future for Main {
if self.shutdown {
return Ok(Async::Ready(()));
} else {
panic!("Spirc shut down unexpectedly");
warn!("Spirc shut down unexpectedly");
self.spirc_task = None;
}
}
}