|
@@ -14,6 +14,7 @@ component! {
|
|
download_rate_estimate: usize = 0,
|
|
download_rate_estimate: usize = 0,
|
|
download_measurement_start: Option<Instant> = None,
|
|
download_measurement_start: Option<Instant> = None,
|
|
download_measurement_bytes: usize = 0,
|
|
download_measurement_bytes: usize = 0,
|
|
|
|
+ is_shutdown: bool = false,
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -46,7 +47,9 @@ impl ChannelManager {
|
|
|
|
|
|
let seq = self.lock(|inner| {
|
|
let seq = self.lock(|inner| {
|
|
let seq = inner.sequence.get();
|
|
let seq = inner.sequence.get();
|
|
- inner.channels.insert(seq, tx);
|
|
|
|
|
|
+ if !inner.is_shutdown {
|
|
|
|
+ inner.channels.insert(seq, tx);
|
|
|
|
+ }
|
|
seq
|
|
seq
|
|
});
|
|
});
|
|
|
|
|
|
@@ -87,6 +90,14 @@ impl ChannelManager {
|
|
pub fn get_download_rate_estimate(&self) -> usize {
|
|
pub fn get_download_rate_estimate(&self) -> usize {
|
|
return self.lock(|inner| inner.download_rate_estimate);
|
|
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 {
|
|
impl Channel {
|