Commit aed84d7c authored by justcoding121's avatar justcoding121

refactor

parent 5e4c5f41
......@@ -155,6 +155,7 @@ namespace Titanium.Web.Proxy
//it could cause floating server connections when client exits
prefetchConnectionTask = getServerConnection(connectArgs, true,
null, false, CancellationToken.None);
try
{
sslStream = new SslStream(clientStream);
......@@ -334,8 +335,6 @@ namespace Titanium.Web.Proxy
}
finally
{
clientStream.Dispose();
if (!calledRequestHandler
&& prefetchConnectionTask != null)
{
......@@ -343,6 +342,8 @@ namespace Titanium.Web.Proxy
await tcpConnectionFactory.Release(connection, closeServerConnection);
}
clientStream.Dispose();
if (!cancellationTokenSource.IsCancellationRequested)
{
cancellationTokenSource.Cancel();
......
......@@ -278,14 +278,14 @@ namespace Titanium.Web.Proxy
}
finally
{
await tcpConnectionFactory.Release(connection,
closeServerConnection);
if (prefetchTask != null)
{
await tcpConnectionFactory.Release(await prefetchTask,
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