Close connection gracefully in Frame.ProduceEnd

- Try sending a FIN before closing the socket
- Don't attempt to send a FIN twice for the same connection
This commit is contained in:
Stephen Halter 2015-10-14 15:29:30 -07:00
parent 513abb4561
commit 7b315d2470
1 changed files with 5 additions and 2 deletions

View File

@ -449,7 +449,7 @@ namespace Microsoft.AspNet.Server.Kestrel.Http
if (_responseStarted)
{
// We can no longer respond with a 500, so we simply close the connection.
ConnectionControl.End(ProduceEndType.SocketDisconnect);
_keepAlive = false;
return;
}
else
@ -475,7 +475,10 @@ namespace Microsoft.AspNet.Server.Kestrel.Http
WriteChunkedResponseSuffix();
}
ConnectionControl.End(_keepAlive ? ProduceEndType.ConnectionKeepAlive : ProduceEndType.SocketShutdownSend);
if (_keepAlive)
{
ConnectionControl.End(ProduceEndType.ConnectionKeepAlive);
}
}
private Tuple<ArraySegment<byte>, IDisposable> CreateResponseHeader(