From e5238ff38310782c4f7338fb6bb380f670a45e39 Mon Sep 17 00:00:00 2001 From: Ben Adams Date: Fri, 22 Jan 2016 23:34:28 +0000 Subject: [PATCH] Only log connection error once --- .../Http/SocketOutput.cs | 21 +++++++++---------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/src/Microsoft.AspNetCore.Server.Kestrel/Http/SocketOutput.cs b/src/Microsoft.AspNetCore.Server.Kestrel/Http/SocketOutput.cs index ebfd3cb55c..eed0230e3e 100644 --- a/src/Microsoft.AspNetCore.Server.Kestrel/Http/SocketOutput.cs +++ b/src/Microsoft.AspNetCore.Server.Kestrel/Http/SocketOutput.cs @@ -294,12 +294,17 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Http { lock (_contextLock) { - // Abort the connection for any failed write - // Queued on threadpool so get it in as first op. - _connection.Abort(); - _cancelled = true; + if (!_cancelled) + { + // Abort the connection for any failed write + // Queued on threadpool so get it in as first op. + _connection.Abort(); + _cancelled = true; - CompleteAllWrites(); + CompleteAllWrites(); + + _log.ConnectionError(_connectionId, new TaskCanceledException("Write operation canceled. Aborting connection.")); + } } } @@ -434,17 +439,11 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Http private void CompleteAllWrites() { // Called inside _contextLock - var writesToComplete = _tasksPending.Count > 0; var bytesLeftToBuffer = _maxBytesPreCompleted - _numBytesPreCompleted; while (_tasksPending.Count > 0) { CompleteNextWrite(ref bytesLeftToBuffer); } - - if (writesToComplete) - { - _log.ConnectionError(_connectionId, new TaskCanceledException("Connetcion")); - } } // This is called on the libuv event loop