mirror of
https://github.com/librespot-org/librespot.git
synced 2024-12-18 17:11:53 +00:00
Enable proper shutdown of the channels.
This commit is contained in:
parent
04b52d7878
commit
ea1e0925dc
2 changed files with 13 additions and 1 deletions
|
@ -14,6 +14,7 @@ component! {
|
|||
download_rate_estimate: usize = 0,
|
||||
download_measurement_start: Option<Instant> = None,
|
||||
download_measurement_bytes: usize = 0,
|
||||
is_shutdown: bool = false,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -46,7 +47,9 @@ impl ChannelManager {
|
|||
|
||||
let seq = self.lock(|inner| {
|
||||
let seq = inner.sequence.get();
|
||||
inner.channels.insert(seq, tx);
|
||||
if !inner.is_shutdown {
|
||||
inner.channels.insert(seq, tx);
|
||||
}
|
||||
seq
|
||||
});
|
||||
|
||||
|
@ -87,6 +90,14 @@ impl ChannelManager {
|
|||
pub fn get_download_rate_estimate(&self) -> usize {
|
||||
return self.lock(|inner| inner.download_rate_estimate);
|
||||
}
|
||||
|
||||
pub(crate) fn shutdown(&self) {
|
||||
self.lock(|inner| {
|
||||
inner.is_shutdown = true;
|
||||
// destroy the sending halves of the channels to signal everyone who is waiting for something.
|
||||
inner.channels.clear();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
impl Channel {
|
||||
|
|
|
@ -238,6 +238,7 @@ impl Session {
|
|||
debug!("Invalidating session[{}]", self.0.session_id);
|
||||
self.0.data.write().unwrap().invalid = true;
|
||||
self.mercury().shutdown();
|
||||
self.channel().shutdown();
|
||||
}
|
||||
|
||||
pub fn is_invalid(&self) -> bool {
|
||||
|
|
Loading…
Reference in a new issue