Unverified Commit 3ef65b2d authored by justcoding121's avatar justcoding121 Committed by GitHub

Merge pull request #465 from justcoding121/master

retry without polly fixes
parents f4e6fe18 823e8b21
...@@ -32,9 +32,9 @@ namespace Titanium.Web.Proxy.Network ...@@ -32,9 +32,9 @@ namespace Titanium.Web.Proxy.Network
Exception exception = null; Exception exception = null;
var attempts = retries; var attempts = retries;
while (attempts >= 0)
while (true)
{ {
try try
{ {
//setup connection //setup connection
...@@ -44,26 +44,29 @@ namespace Titanium.Web.Proxy.Network ...@@ -44,26 +44,29 @@ namespace Titanium.Web.Proxy.Network
@continue = await action(currentConnection); @continue = await action(currentConnection);
} }
catch (T ex) catch (Exception ex)
{ {
exception = ex; exception = ex;
await onRetry(ex);
} }
if(exception == null) attempts--;
if (attempts < 0
|| exception == null
|| !(exception is T))
{ {
break; break;
} }
exception = null; exception = null;
attempts--; await disposeConnection();
} }
return new RetryResult(currentConnection, exception, @continue); return new RetryResult(currentConnection, exception, @continue);
} }
//before retry clear connection //before retry clear connection
private async Task onRetry(Exception ex) private async Task disposeConnection()
{ {
if (currentConnection != null) if (currentConnection != null)
{ {
......
...@@ -267,7 +267,8 @@ namespace Titanium.Web.Proxy ...@@ -267,7 +267,8 @@ namespace Titanium.Web.Proxy
//between sessions without using it. //between sessions without using it.
//Do not release authenticated connections for performance reasons. //Do not release authenticated connections for performance reasons.
//Otherwise it will keep authenticating per session. //Otherwise it will keep authenticating per session.
if (EnableConnectionPool && !connection.IsWinAuthenticated) if (EnableConnectionPool && connection!=null
&& !connection.IsWinAuthenticated)
{ {
await tcpConnectionFactory.Release(connection); await tcpConnectionFactory.Release(connection);
connection = null; connection = null;
......
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