TorHttpPool: Do not re-use a connection with failed HTTP request.
MODIFY
WalletWasabi/Tor/Socks5/Pool/TorHttpPool.cs
WalletWasabi/Tor/Socks5/Pool/TorHttpPool.cs
@@ -163,7 +163,11 @@ namespace WalletWasabi.Tor.Socks5.Pool
}
finally
{
- connectionToDispose?.Dispose();
+ if (connectionToDispose is not null)
+ {
+ Logger.LogTrace($"['{connectionToDispose}'] marked as to be disposed.");
+ connectionToDispose.MarkAsToDispose();
+ }
}
} while (i < attemptsNo);
}

MODIFY
WalletWasabi/Tor/Socks5/TorTcpConnection.cs
WalletWasabi/Tor/Socks5/TorTcpConnection.cs
@@ -91,6 +91,16 @@ namespace WalletWasabi.Tor.Socks5
}
}
+ /// <remarks>Connection transporting an HTTP request that was canceled or otherwise failed must be torn down.</remarks>
+ public void MarkAsToDispose()
+ {
+ lock (StateLock)
+ {
+ Debug.Assert(State == TcpConnectionState.InUse, $"Unexpected state: '{State}'.");
+ State = TcpConnectionState.ToDispose;
+ }
+ }
+
/// <inheritdoc/>
public override string ToString()
{

TorHttpPool: Do not re-use a connection with failed HTTP request.