From 6bff2ecb3420084c34563ceb3cbae448d0c86ca0 Mon Sep 17 00:00:00 2001 From: Stephen Halter Date: Wed, 1 Jun 2016 12:04:48 -0700 Subject: [PATCH] Small cleanup to SocketOutput's shutdown logic --- .../Http/SocketOutput.cs | 17 ++++++----------- .../SocketOutputTests.cs | 1 - 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/src/Microsoft.AspNetCore.Server.Kestrel/Http/SocketOutput.cs b/src/Microsoft.AspNetCore.Server.Kestrel/Http/SocketOutput.cs index f0b23651e7..8b3ec4f042 100644 --- a/src/Microsoft.AspNetCore.Server.Kestrel/Http/SocketOutput.cs +++ b/src/Microsoft.AspNetCore.Server.Kestrel/Http/SocketOutput.cs @@ -248,7 +248,7 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Http public void ProducingComplete(MemoryPoolIterator end) { - if(_lastStart.IsDefault) + if (_lastStart.IsDefault) { return; } @@ -560,7 +560,6 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Http public int WriteStatus; public Exception WriteError; - public int ShutdownSendStatus; public WriteContext(SocketOutput self) { @@ -625,15 +624,13 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Http var shutdownReq = new UvShutdownReq(Self._log); shutdownReq.Init(Self._thread.Loop); - shutdownReq.Shutdown(Self._socket, (_shutdownReq, status, state) => + shutdownReq.Shutdown(Self._socket, (req, status, state) => { - _shutdownReq.Dispose(); - var _this = (WriteContext)state; - _this.ShutdownSendStatus = status; + req.Dispose(); - _this.Self._log.ConnectionWroteFin(_this.Self._connectionId, status); - - _this.DoDisconnectIfNeeded(); + var writeContext = (WriteContext)state; + writeContext.Self._log.ConnectionWroteFin(writeContext.Self._connectionId, status); + writeContext.DoDisconnectIfNeeded(); }, this); } @@ -762,8 +759,6 @@ namespace Microsoft.AspNetCore.Server.Kestrel.Http WriteStatus = 0; WriteError = null; - - ShutdownSendStatus = 0; } } diff --git a/test/Microsoft.AspNetCore.Server.KestrelTests/SocketOutputTests.cs b/test/Microsoft.AspNetCore.Server.KestrelTests/SocketOutputTests.cs index ab29f4cc4b..a398c5cb66 100644 --- a/test/Microsoft.AspNetCore.Server.KestrelTests/SocketOutputTests.cs +++ b/test/Microsoft.AspNetCore.Server.KestrelTests/SocketOutputTests.cs @@ -683,7 +683,6 @@ namespace Microsoft.AspNetCore.Server.KestrelTests Assert.True(start.IsDefault); // ProducingComplete should not throw given a default iterator socketOutput.ProducingComplete(start); - } } }