mirror of
https://github.com/librespot-org/librespot.git
synced 2024-12-18 17:11:53 +00:00
Prevent librespot from panicking if server connection is lost.
This commit is contained in:
parent
362106df62
commit
b6c676ad60
2 changed files with 9 additions and 3 deletions
|
@ -283,13 +283,18 @@ where
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
let (cmd, data) = match self.0.poll() {
|
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),
|
Ok(Async::NotReady) => return Ok(Async::NotReady),
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
session.shutdown();
|
session.shutdown();
|
||||||
return Err(From::from(e));
|
return Err(From::from(e));
|
||||||
}
|
}
|
||||||
}.expect("connection closed");
|
};
|
||||||
|
|
||||||
session.dispatch(cmd, data);
|
session.dispatch(cmd, data);
|
||||||
}
|
}
|
||||||
|
|
|
@ -500,7 +500,8 @@ impl Future for Main {
|
||||||
if self.shutdown {
|
if self.shutdown {
|
||||||
return Ok(Async::Ready(()));
|
return Ok(Async::Ready(()));
|
||||||
} else {
|
} else {
|
||||||
panic!("Spirc shut down unexpectedly");
|
warn!("Spirc shut down unexpectedly");
|
||||||
|
self.spirc_task = None;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue