Commit c5b87959 authored by justcoding121's avatar justcoding121

refactor prefetch release

parent 4caac342
......@@ -341,15 +341,7 @@ namespace Titanium.Web.Proxy
if (!calledRequestHandler
&& prefetchConnectionTask != null)
{
TcpServerConnection prefetchedConnection = null;
try
{
prefetchedConnection = await prefetchConnectionTask;
}
finally
{
await tcpConnectionFactory.Release(prefetchedConnection, closeServerConnection);
}
await tcpConnectionFactory.Release(prefetchConnectionTask, closeServerConnection);
}
clientStream.Dispose();
......
......@@ -403,6 +403,23 @@ namespace Titanium.Web.Proxy.Network.Tcp
}
}
internal async Task Release(Task<TcpServerConnection> connectionCreateTask, bool closeServerConnection)
{
if (connectionCreateTask != null)
{
TcpServerConnection connection = null;
try
{
connection = await connectionCreateTask;
}
catch { }
finally
{
await Release(connection, closeServerConnection);
}
}
}
private async Task clearOutdatedConnections()
{
while (runCleanUpTask)
......
......@@ -280,19 +280,7 @@ namespace Titanium.Web.Proxy
await tcpConnectionFactory.Release(connection,
closeServerConnection);
if (prefetchTask != null)
{
TcpServerConnection prefetchedConnection = null;
try
{
prefetchedConnection = await prefetchTask;
}
finally
{
await tcpConnectionFactory.Release(prefetchedConnection, closeServerConnection);
}
}
await tcpConnectionFactory.Release(prefetchTask, closeServerConnection);
}
}
......
......@@ -167,15 +167,7 @@ namespace Titanium.Web.Proxy
if (!calledRequestHandler
&& prefetchConnectionTask != null)
{
TcpServerConnection prefetchedConnection = null;
try
{
prefetchedConnection = await prefetchConnectionTask;
}
finally
{
await tcpConnectionFactory.Release(prefetchedConnection, closeServerConnection);
}
await tcpConnectionFactory.Release(prefetchConnectionTask, closeServerConnection);
}
clientStream.Dispose();
......
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