Commit abc21b87 authored by justcoding121's avatar justcoding121

remove lock on get

parent 022b4762
......@@ -94,34 +94,25 @@ namespace Titanium.Web.Proxy.Network.Tcp
if (proxyServer.EnableConnectionPool)
{
try
if (cache.TryGetValue(cacheKey, out var existingConnections))
{
await @lock.WaitAsync();
if (cache.TryGetValue(cacheKey, out var existingConnections))
while (existingConnections.Count > 0)
{
while (existingConnections.Count > 0)
if (existingConnections.TryDequeue(out var recentConnection))
{
if (existingConnections.TryDequeue(out var recentConnection))
{
//+3 seconds for potential delay after getting connection
var cutOff = DateTime.Now.AddSeconds(-1 * proxyServer.ConnectionTimeOutSeconds + 3);
if (recentConnection.LastAccess > cutOff
&& isGoodConnection(recentConnection.TcpClient))
{
return recentConnection;
}
//+3 seconds for potential delay after getting connection
var cutOff = DateTime.Now.AddSeconds(-1 * proxyServer.ConnectionTimeOutSeconds + 3);
disposalBag.Add(recentConnection);
if (recentConnection.LastAccess > cutOff
&& isGoodConnection(recentConnection.TcpClient))
{
return recentConnection;
}
disposalBag.Add(recentConnection);
}
}
}
finally
{
@lock.Release();
}
}
var connection = await createClient(remoteHostName, remotePort, httpVersion, isHttps,
......
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