connection: wake 'stopped' streams on stream finish events

In the event that the SendStream Stopped future is polled once and then dropped
before the remote side has stopped the stream, and instead the stream
has been finished, the waker registered in the connection stopped map is
never removed and is effectively "leaked" until the connection is
closed. This can lead to a large amount of memory being retained when a
connection is very long lived and many streams are used over the life of
that connection.
This commit is contained in:
Brandon Williams
2022-11-29 09:54:56 -08:00
committed by Benjamin Saunders
parent cfb7a067ee
commit 1122c627c3
+3
View File
@@ -966,6 +966,9 @@ impl State {
// If the finishing stream was already dropped, there's nothing more to do.
let _ = finishing.send(None);
}
if let Some(stopped) = self.stopped.remove(&id) {
stopped.wake();
}
}
Stream(StreamEvent::Stopped { id, error_code }) => {
if let Some(stopped) = self.stopped.remove(&id) {