mplex: fix destroy_substream (#469)

Retain all incoming buffer elements with different substream ID or equal
Endpoint. The latter was previously not considered which could result in
the removal of data for another substream with same ID but opposite
Endpoint.
This commit is contained in:
Toralf Wittner 2018-09-10 10:21:19 +02:00 committed by GitHub
parent 304e9c72c8
commit ec6ec92a79
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -506,7 +506,9 @@ where C: AsyncRead + AsyncWrite
fn destroy_substream(&self, mut substream: Self::Substream) {
let _ = self.shutdown_substream(&mut substream); // TODO: this doesn't necessarily send the close message
self.inner.lock().buffer.retain(|elem| elem.substream_id() != substream.num);
self.inner.lock().buffer.retain(|elem| {
elem.substream_id() != substream.num || elem.endpoint() == Some(substream.endpoint)
})
}
}