File tree Expand file tree Collapse file tree 1 file changed +5
-7
lines changed
src/libraries/System.Net.Http.WinHttpHandler/src/System/Net/Http Expand file tree Collapse file tree 1 file changed +5
-7
lines changed Original file line number Diff line number Diff line change @@ -90,7 +90,7 @@ private Func<
90
90
private int _maxResponseDrainSize = HttpHandlerDefaults . DefaultMaxResponseDrainSize ;
91
91
private IDictionary < string , object > ? _properties ; // Only create dictionary when required.
92
92
private volatile bool _operationStarted ;
93
- private volatile bool _disposed ;
93
+ private volatile int _disposed ;
94
94
private SafeWinHttpHandle ? _sessionHandle ;
95
95
private readonly WinHttpAuthHelper _authHelper = new WinHttpAuthHelper ( ) ;
96
96
@@ -539,13 +539,11 @@ public bool EnableMultipleHttp2Connections
539
539
540
540
protected override void Dispose ( bool disposing )
541
541
{
542
- if ( ! _disposed )
542
+ if ( Interlocked . CompareExchange ( ref _disposed , 1 , 0 ) == 0 )
543
543
{
544
- _disposed = true ;
545
-
546
544
if ( disposing && _sessionHandle != null )
547
545
{
548
- SafeWinHttpHandle . DisposeAndClearHandle ( ref _sessionHandle ) ;
546
+ _sessionHandle . Dispose ( ) ;
549
547
}
550
548
}
551
549
@@ -1033,7 +1031,7 @@ private async Task StartRequestAsync(WinHttpRequestState state)
1033
1031
}
1034
1032
finally
1035
1033
{
1036
- SafeWinHttpHandle . DisposeAndClearHandle ( ref connectHandle ) ;
1034
+ connectHandle ? . Dispose ( ) ;
1037
1035
1038
1036
try
1039
1037
{
@@ -1620,7 +1618,7 @@ private void SetOperationStarted()
1620
1618
1621
1619
private void CheckDisposed ( )
1622
1620
{
1623
- if ( _disposed )
1621
+ if ( _disposed == 1 )
1624
1622
{
1625
1623
throw new ObjectDisposedException ( GetType ( ) . FullName ) ;
1626
1624
}
You can’t perform that action at this time.
0 commit comments