remove unnecessary call (#55795)
authorTomas Weinfurt <tweinfurt@yahoo.com>
Tue, 20 Jul 2021 17:20:51 +0000 (10:20 -0700)
committerGitHub <noreply@github.com>
Tue, 20 Jul 2021 17:20:51 +0000 (10:20 -0700)
* remove unnecessary call

* fix typo

src/libraries/System.Net.Quic/src/System/Net/Quic/Implementations/MsQuic/MsQuicConnection.cs

index 39bd5e80f6cef0166940596c395b4e125d5dfb2d..ef881266891de70a1fcd7bc8353bfbe1fed74036 100644 (file)
@@ -27,7 +27,7 @@ namespace System.Net.Quic.Implementations.MsQuic
 
         // TODO: remove this.
         // This is only used for client-initiated connections, and isn't needed even then once Connect() has been called.
-        private readonly SafeMsQuicConfigurationHandle? _configuration;
+        private SafeMsQuicConfigurationHandle? _configuration;
 
         private readonly State _state = new State();
         private int _disposed;
@@ -188,9 +188,6 @@ namespace System.Net.Quic.Implementations.MsQuic
             _state.StateGCHandle = GCHandle.Alloc(_state);
             try
             {
-                // this handle is ref counted by MsQuic, so safe to dispose here.
-                using SafeMsQuicConfigurationHandle config = SafeMsQuicConfigurationHandle.Create(options);
-
                 uint status = MsQuicApi.Api.ConnectionOpenDelegate(
                     MsQuicApi.Api.Registration,
                     s_connectionDelegate,
@@ -575,6 +572,10 @@ namespace System.Net.Quic.Implementations.MsQuic
                     (ushort)port);
 
                 QuicExceptionHelpers.ThrowIfFailed(status, "Failed to connect to peer.");
+
+                // this handle is ref counted by MsQuic, so safe to dispose here.
+                _configuration.Dispose();
+                _configuration = null;
             }
             catch
             {