Skip to content
This repository was archived by the owner on Jul 9, 2023. It is now read-only.

Commit 3ef65b2

Browse files
Merge pull request #465 from justcoding121/master
retry without polly fixes
2 parents f4e6fe1 + 823e8b2 commit 3ef65b2

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

Titanium.Web.Proxy/Network/RetryPolicy.cs

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ internal async Task<RetryResult> ExecuteAsync(Func<TcpServerConnection, Task<boo
3232
Exception exception = null;
3333

3434
var attempts = retries;
35-
while (attempts >= 0)
35+
36+
while (true)
3637
{
37-
3838
try
3939
{
4040
//setup connection
@@ -44,26 +44,29 @@ internal async Task<RetryResult> ExecuteAsync(Func<TcpServerConnection, Task<boo
4444
@continue = await action(currentConnection);
4545

4646
}
47-
catch (T ex)
48-
{
47+
catch (Exception ex)
48+
{
4949
exception = ex;
50-
await onRetry(ex);
5150
}
5251

53-
if(exception == null)
52+
attempts--;
53+
54+
if (attempts < 0
55+
|| exception == null
56+
|| !(exception is T))
5457
{
5558
break;
5659
}
5760

5861
exception = null;
59-
attempts--;
62+
await disposeConnection();
6063
}
6164

6265
return new RetryResult(currentConnection, exception, @continue);
6366
}
6467

6568
//before retry clear connection
66-
private async Task onRetry(Exception ex)
69+
private async Task disposeConnection()
6770
{
6871
if (currentConnection != null)
6972
{

Titanium.Web.Proxy/RequestHandler.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,8 @@ await handleWebSocketUpgrade(httpCmd, args, request,
267267
//between sessions without using it.
268268
//Do not release authenticated connections for performance reasons.
269269
//Otherwise it will keep authenticating per session.
270-
if (EnableConnectionPool && !connection.IsWinAuthenticated)
270+
if (EnableConnectionPool && connection!=null
271+
&& !connection.IsWinAuthenticated)
271272
{
272273
await tcpConnectionFactory.Release(connection);
273274
connection = null;

0 commit comments

Comments
 (0)