This repository was archived by the owner on Dec 18, 2018. It is now read-only.
File tree 1 file changed +5
-3
lines changed
src/Microsoft.AspNet.Server.Kestrel/Http 1 file changed +5
-3
lines changed Original file line number Diff line number Diff line change 5
5
using System . IO ;
6
6
using System . Runtime . CompilerServices ;
7
7
using System . Threading ;
8
- using System . Threading . Tasks ;
9
8
using Microsoft . AspNet . Server . Kestrel . Infrastructure ;
10
9
11
10
namespace Microsoft . AspNet . Server . Kestrel . Http
@@ -40,7 +39,7 @@ public bool IsCompleted
40
39
{
41
40
get
42
41
{
43
- return Equals ( _awaitableState , _awaitableIsCompleted ) ;
42
+ return _awaitableState == _awaitableIsCompleted ;
44
43
}
45
44
}
46
45
@@ -128,6 +127,7 @@ public void IncomingComplete(int count, Exception error)
128
127
if ( awaitableState != _awaitableIsCompleted &&
129
128
awaitableState != _awaitableIsNotCompleted )
130
129
{
130
+ // Waiting read, run it on thread pool rather than IO thread
131
131
ThreadPool . QueueUserWorkItem ( ( o ) => ( ( Action ) o ) ( ) , awaitableState ) ;
132
132
}
133
133
}
@@ -194,11 +194,13 @@ public void OnCompleted(Action continuation)
194
194
}
195
195
else if ( awaitableState == _awaitableIsCompleted )
196
196
{
197
- ThreadPool . QueueUserWorkItem ( ( o ) => ( ( Action ) o ) ( ) , continuation ) ;
197
+ // Read already completed, continue on calling thread
198
+ continuation ( ) ;
198
199
}
199
200
else
200
201
{
201
202
// THIS IS AN ERROR STATE - ONLY ONE WAITER CAN WAIT
203
+ throw new InvalidOperationException ( "Already an awaited read" ) ;
202
204
}
203
205
}
204
206
You can’t perform that action at this time.
0 commit comments