@@ -49,7 +49,7 @@ public class Http1OutputProducer : IHttpOutputProducer, IHttpOutputAborter, IDis
49
49
private int _advancedBytesForChunk ;
50
50
private Memory < byte > _currentChunkMemory ;
51
51
private bool _currentChunkMemoryUpdated ;
52
- private IMemoryOwner < byte > _completedMemoryOwner ;
52
+ private IMemoryOwner < byte > _fakeMemoryOwner ;
53
53
54
54
public Http1OutputProducer (
55
55
PipeWriter pipeWriter ,
@@ -230,19 +230,24 @@ public void Dispose()
230
230
{
231
231
lock ( _contextLock )
232
232
{
233
- if ( _completedMemoryOwner != null )
233
+ if ( _fakeMemoryOwner != null )
234
234
{
235
- _completedMemoryOwner . Dispose ( ) ;
236
- _completedMemoryOwner = null ;
235
+ _fakeMemoryOwner . Dispose ( ) ;
236
+ _fakeMemoryOwner = null ;
237
237
}
238
238
239
- if ( ! _pipeWriterCompleted )
240
- {
241
- _log . ConnectionDisconnect ( _connectionId ) ;
242
- _pipeWriterCompleted = true ;
243
- _completed = true ;
244
- _pipeWriter . Complete ( ) ;
245
- }
239
+ CompletePipe ( ) ;
240
+ }
241
+ }
242
+
243
+ private void CompletePipe ( )
244
+ {
245
+ if ( ! _pipeWriterCompleted )
246
+ {
247
+ _log . ConnectionDisconnect ( _connectionId ) ;
248
+ _pipeWriterCompleted = true ;
249
+ _completed = true ;
250
+ _pipeWriter . Complete ( ) ;
246
251
}
247
252
}
248
253
@@ -259,7 +264,8 @@ public void Abort(ConnectionAbortedException error)
259
264
260
265
_aborted = true ;
261
266
_connectionContext . Abort ( error ) ;
262
- Dispose ( ) ;
267
+
268
+ CompletePipe ( ) ;
263
269
}
264
270
}
265
271
@@ -379,11 +385,11 @@ private void WriteCurrentMemoryToPipeWriter()
379
385
380
386
private Memory < byte > GetFakeMemory ( int sizeHint )
381
387
{
382
- if ( _completedMemoryOwner == null )
388
+ if ( _fakeMemoryOwner == null )
383
389
{
384
- _completedMemoryOwner = _memoryPool . Rent ( sizeHint ) ;
390
+ _fakeMemoryOwner = _memoryPool . Rent ( sizeHint ) ;
385
391
}
386
- return _completedMemoryOwner . Memory ;
392
+ return _fakeMemoryOwner . Memory ;
387
393
}
388
394
}
389
395
}
0 commit comments