From 4dc8ec1bbd2a6a24184ca280cb1d4d28cb950e57 Mon Sep 17 00:00:00 2001 From: Tangent Wantwight Date: Mon, 10 Aug 2020 18:45:14 -0400 Subject: [PATCH] when disconnecting, clean up the header chunk so subsequent clients don't get a potentially incorrect initialization segment --- CHANGELOG.md | 3 +++ Cargo.lock | 2 +- Cargo.toml | 2 +- src/channel.rs | 10 ++++++++++ 4 files changed, 15 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cfd5163..f590dc6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +## v0.3.1-dev +- forget a channel's initialization segment when no transmitter is active. This improves behavior when a channel is occasionally used for streams with different codecs. + ## v0.3.0 - update internals to v0.2 of `warp` and `tokio`; no remaining code relies on `futures` 0.1 diff --git a/Cargo.lock b/Cargo.lock index 7e2d3a4..703066e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1227,7 +1227,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "webmetro" -version = "0.3.0-dev" +version = "0.3.1-dev" dependencies = [ "byteorder 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)", "bytes 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/Cargo.toml b/Cargo.toml index ab42892..1dc41b5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "webmetro" -version = "0.3.0-dev" +version = "0.3.1-dev" authors = ["Tangent 128 "] edition = "2018" diff --git a/src/channel.rs b/src/channel.rs index e52c4a5..d72c65f 100644 --- a/src/channel.rs +++ b/src/channel.rs @@ -57,6 +57,16 @@ impl Transmitter { } } +impl Drop for Transmitter { + fn drop(&mut self) { + if let Ok(mut channel) = self.channel.lock() { + // when disconnecting, clean up the header chunk so subsequent + // clients don't get a potentially incorrect initialization segment + channel.header_chunk = None; + } + } +} + pub struct Listener { /// not used in operation, but its refcount keeps the channel alive when there's no Transmitter _channel: Handle,