From 343728ed3b833110516e13a1c6c73769cfce4f0d Mon Sep 17 00:00:00 2001 From: Stephen Toub Date: Mon, 15 Jul 2019 17:17:18 -0400 Subject: [PATCH] Propagate correct exception in Http2Connection.Abort (dotnet/corefx#39496) Ensure we pass the `_abortException`, not `abortException`, to the streams, and log any non-duplicate exception. Commit migrated from https://github.com/dotnet/corefx/commit/cfccc26f9e77fa9f745857ec48a256309e29f39d --- .../src/System/Net/Http/SocketsHttpHandler/Http2Connection.cs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/Http2Connection.cs b/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/Http2Connection.cs index 6ea5cd0..b6d719d 100644 --- a/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/Http2Connection.cs +++ b/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/Http2Connection.cs @@ -1277,8 +1277,15 @@ namespace System.Net.Http private void Abort(Exception abortException) { // The connection has failed, e.g. failed IO or a connection-level frame error. - Interlocked.CompareExchange(ref _abortException, abortException, null); - AbortStreams(abortException); + if (Interlocked.CompareExchange(ref _abortException, abortException, null) != null && + NetEventSource.IsEnabled && + !ReferenceEquals(_abortException, abortException)) + { + // Lost the race to set the field to another exception, so just trace this one. + Trace($"{nameof(abortException)}=={abortException}"); + } + + AbortStreams(_abortException); } /// Gets whether the connection exceeded any of the connection limits. -- 2.7.4