Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ private Func<
private int _maxResponseDrainSize = HttpHandlerDefaults.DefaultMaxResponseDrainSize;
private IDictionary<string, object>? _properties; // Only create dictionary when required.
private volatile bool _operationStarted;
private volatile bool _disposed;
private volatile int _disposed;
private SafeWinHttpHandle? _sessionHandle;
private readonly WinHttpAuthHelper _authHelper = new WinHttpAuthHelper();

Expand Down Expand Up @@ -539,13 +539,11 @@ public bool EnableMultipleHttp2Connections

protected override void Dispose(bool disposing)
{
if (!_disposed)
if (Interlocked.CompareExchange(ref _disposed, 1, 0) == 0)
{
_disposed = true;

if (disposing && _sessionHandle != null)
{
SafeWinHttpHandle.DisposeAndClearHandle(ref _sessionHandle);
_sessionHandle.Dispose();
}
}

Expand Down Expand Up @@ -1033,7 +1031,7 @@ private async Task StartRequestAsync(WinHttpRequestState state)
}
finally
{
SafeWinHttpHandle.DisposeAndClearHandle(ref connectHandle);
connectHandle?.Dispose();

try
{
Expand Down Expand Up @@ -1620,7 +1618,7 @@ private void SetOperationStarted()

private void CheckDisposed()
{
if (_disposed)
if (_disposed == 1)
{
throw new ObjectDisposedException(GetType().FullName);
}
Expand Down
Loading