Commit 808ddab4 authored by justcoding121's avatar justcoding121

refactor

parent dc486d7d
...@@ -155,6 +155,7 @@ namespace Titanium.Web.Proxy ...@@ -155,6 +155,7 @@ namespace Titanium.Web.Proxy
//it could cause floating server connections when client exits //it could cause floating server connections when client exits
prefetchConnectionTask = getServerConnection(connectArgs, true, prefetchConnectionTask = getServerConnection(connectArgs, true,
null, false, CancellationToken.None); null, false, CancellationToken.None);
try try
{ {
sslStream = new SslStream(clientStream); sslStream = new SslStream(clientStream);
...@@ -334,8 +335,6 @@ namespace Titanium.Web.Proxy ...@@ -334,8 +335,6 @@ namespace Titanium.Web.Proxy
} }
finally finally
{ {
clientStream.Dispose();
if (!calledRequestHandler if (!calledRequestHandler
&& prefetchConnectionTask != null) && prefetchConnectionTask != null)
{ {
...@@ -343,6 +342,8 @@ namespace Titanium.Web.Proxy ...@@ -343,6 +342,8 @@ namespace Titanium.Web.Proxy
await tcpConnectionFactory.Release(connection, closeServerConnection); await tcpConnectionFactory.Release(connection, closeServerConnection);
} }
clientStream.Dispose();
if (!cancellationTokenSource.IsCancellationRequested) if (!cancellationTokenSource.IsCancellationRequested)
{ {
cancellationTokenSource.Cancel(); cancellationTokenSource.Cancel();
......
...@@ -278,14 +278,14 @@ namespace Titanium.Web.Proxy ...@@ -278,14 +278,14 @@ namespace Titanium.Web.Proxy
} }
finally finally
{ {
await tcpConnectionFactory.Release(connection,
closeServerConnection);
if (prefetchTask != null) if (prefetchTask != null)
{ {
await tcpConnectionFactory.Release(await prefetchTask, await tcpConnectionFactory.Release(await prefetchTask,
closeServerConnection); closeServerConnection);
} }
await tcpConnectionFactory.Release(connection,
closeServerConnection);
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment