Commit ab632d8e authored by justcoding121's avatar justcoding121

refactor prefetch release

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