This repository was archived by the owner on Dec 18, 2018. It is now read-only.
File tree Expand file tree Collapse file tree 6 files changed +18
-19
lines changed
src/Microsoft.AspNetCore.Server.Kestrel.Core/Internal/Http
Microsoft.AspNetCore.Server.Kestrel.Core.Tests
Microsoft.AspNetCore.Server.Kestrel.FunctionalTests Expand file tree Collapse file tree 6 files changed +18
-19
lines changed Original file line number Diff line number Diff line change @@ -163,13 +163,9 @@ public override async Task ProcessRequestsAsync()
163
163
TimeoutControl . SetTimeout ( Constants . RequestBodyDrainTimeout . Ticks , TimeoutAction . SendTimeoutResponse ) ;
164
164
await messageBody . ConsumeAsync ( ) ;
165
165
TimeoutControl . CancelTimeout ( ) ;
166
-
167
- // At this point both the request body pipe reader and writer should be completed.
168
- RequestBodyPipe . Reset ( ) ;
169
166
}
170
167
else
171
168
{
172
- RequestBodyPipe . Reader . Complete ( ) ;
173
169
messageBody . Cancel ( ) ;
174
170
Input . CancelPendingRead ( ) ;
175
171
}
@@ -201,6 +197,14 @@ public override async Task ProcessRequestsAsync()
201
197
// StopStreams should be called before the end of the "if (!_requestProcessingStopping)" block
202
198
// to ensure InitializeStreams has been called.
203
199
StopStreams ( ) ;
200
+
201
+ if ( HasStartedConsumingRequestBody )
202
+ {
203
+ RequestBodyPipe . Reader . Complete ( ) ;
204
+
205
+ // At this point both the request body pipe reader and writer should be completed.
206
+ RequestBodyPipe . Reset ( ) ;
207
+ }
204
208
}
205
209
}
206
210
Original file line number Diff line number Diff line change @@ -204,19 +204,12 @@ public void Cancel()
204
204
{
205
205
TryInit ( ) ;
206
206
207
- try
207
+ ReadResult result ;
208
+ do
208
209
{
209
- ReadResult result ;
210
- do
211
- {
212
- result = await _context . RequestBodyPipe . Reader . ReadAsync ( ) ;
213
- _context . RequestBodyPipe . Reader . Advance ( result . Buffer . End ) ;
214
- } while ( ! result . IsCompleted ) ;
215
- }
216
- finally
217
- {
218
- _context . RequestBodyPipe . Reader . Complete ( ) ;
219
- }
210
+ result = await _context . RequestBodyPipe . Reader . ReadAsync ( ) ;
211
+ _context . RequestBodyPipe . Reader . Advance ( result . Buffer . End ) ;
212
+ } while ( ! result . IsCompleted ) ;
220
213
}
221
214
222
215
protected void Copy ( ReadableBuffer readableBuffer , WritableBuffer writableBuffer )
Original file line number Diff line number Diff line change @@ -349,7 +349,7 @@ public async Task CopyToAsyncDoesNotCompletePipeReader()
349
349
}
350
350
351
351
[ Fact ]
352
- public async Task ConsumeAsyncCompletesPipeReader ( )
352
+ public async Task ConsumeAsyncConsumesAllRemainingInput ( )
353
353
{
354
354
using ( var input = new TestInput ( ) )
355
355
{
@@ -359,7 +359,7 @@ public async Task ConsumeAsyncCompletesPipeReader()
359
359
360
360
await body . ConsumeAsync ( ) ;
361
361
362
- await Assert . ThrowsAsync < InvalidOperationException > ( async ( ) => await body . ReadAsync ( new ArraySegment < byte > ( new byte [ 1 ] ) ) ) ;
362
+ Assert . Equal ( 0 , await body . ReadAsync ( new ArraySegment < byte > ( new byte [ 1 ] ) ) ) ;
363
363
}
364
364
}
365
365
Original file line number Diff line number Diff line change @@ -16,7 +16,8 @@ namespace Microsoft.AspNetCore.Server.Kestrel.FunctionalTests
16
16
{
17
17
public class FrameConnectionManagerTests
18
18
{
19
-
19
+ // This test causes MemoryPoolBlocks to be finalized which in turn causes an assert failure in debug builds.
20
+ #if ! DEBUG
20
21
[ ConditionalFact ]
21
22
[ NoDebuggerCondition ]
22
23
public async Task CriticalErrorLoggedIfApplicationDoesntComplete ( )
@@ -65,6 +66,7 @@ public async Task CriticalErrorLoggedIfApplicationDoesntComplete()
65
66
Assert . True ( logWaitAttempts < 10 ) ;
66
67
}
67
68
}
69
+ #endif
68
70
69
71
private class NoDebuggerConditionAttribute : Attribute , ITestCondition
70
72
{
File renamed without changes.
File renamed without changes.
You can’t perform that action at this time.
0 commit comments