Skip to content
This repository was archived by the owner on Dec 18, 2018. It is now read-only.

Commit d5baac8

Browse files
author
Kai Ruhnau
committed
Early-exit when the connection is closed
1 parent 9fc2715 commit d5baac8

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

src/Microsoft.AspNet.Server.Kestrel/Http/Connection.cs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -80,13 +80,8 @@ private void OnRead(int status, Exception error)
8080

8181
var normalRead = error == null && status > 0;
8282
var normalDone = status == 0 || status == -4077 || status == -4095;
83-
var errorDone = !(normalDone || normalRead);
8483

85-
if (normalRead)
86-
{
87-
KestrelTrace.Log.ConnectionRead(_connectionId, status);
88-
}
89-
else if (normalDone || errorDone)
84+
if (!normalRead)
9085
{
9186
KestrelTrace.Log.ConnectionReadFin(_connectionId);
9287
SocketInput.RemoteIntakeFin = true;
@@ -95,12 +90,18 @@ private void OnRead(int status, Exception error)
9590
_listener.RemoveConnection(this);
9691
_socket.Dispose();
9792

98-
if (errorDone && error != null)
93+
if (!normalDone && error != null)
9994
{
10095
Trace.WriteLine("Connection.OnRead " + error.ToString());
10196
}
97+
98+
// Not sure if this is right
99+
// It should be, but there are some interesting code paths
100+
// while reading the message body regarding status == 0 && RemoteIntakeFin
101+
return;
102102
}
103103

104+
KestrelTrace.Log.ConnectionRead(_connectionId, status);
104105

105106
try
106107
{

0 commit comments

Comments
 (0)