From 4ecfc51678260d0df62be0a933d8ae6a6add89ad Mon Sep 17 00:00:00 2001 From: Jason Ginchereau Date: Mon, 17 Jul 2023 11:02:55 -1000 Subject: [PATCH] Dispose non-reconnectable streams --- cs/src/Connections/TunnelClient.cs | 10 +++++++--- ts/src/connections/tunnelClientBase.ts | 4 +++- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/cs/src/Connections/TunnelClient.cs b/cs/src/Connections/TunnelClient.cs index b730d166..9742bf7a 100644 --- a/cs/src/Connections/TunnelClient.cs +++ b/cs/src/Connections/TunnelClient.cs @@ -302,9 +302,13 @@ private void OnForwardedPortAdded(PortForwardingService pfs, ForwardedPortEventA lock (this.disconnectedStreams) { // The host is no longer accepting connections on the forwarded port? - // Clear the list of disconnected streams for the port, because - // it seems it is no longer possible to reconnect them. - streams.Clear(); + // Dispose and clear the list of disconnected streams for the port, + // because it seems it is no longer possible to reconnect them. + while (streams.Count > 0) + { + streams[0].Dispose(); + streams.RemoveAt(0); + } } } }); diff --git a/ts/src/connections/tunnelClientBase.ts b/ts/src/connections/tunnelClientBase.ts index 8483357b..71e5bbf4 100644 --- a/ts/src/connections/tunnelClientBase.ts +++ b/ts/src/connections/tunnelClientBase.ts @@ -275,7 +275,9 @@ export class TunnelClientBase // it seems it is no longer possible to reconnect them. const streams = this.disconnectedStreams.get(port); if (streams) { - streams.splice(0, streams.length); + while (streams.length > 0) { + streams.pop()!.dispose(); + } } }); }