@@ -65,6 +65,12 @@ public Http3ControlStream(Http3StreamContext context, long? headerType)
6565 context . ClientPeerSettings ,
6666 this ) ;
6767 _frameWriter . Reset ( context . Transport . Output , context . ConnectionId ) ;
68+
69+ _streamClosedFeature . OnClosed ( static state =>
70+ {
71+ var stream = ( Http3ControlStream ) state ! ;
72+ stream . OnStreamClosed ( ) ;
73+ } , this ) ;
6874 }
6975
7076 private void OnStreamClosed ( )
@@ -135,12 +141,6 @@ private bool TryClose()
135141
136142 internal async ValueTask ProcessOutboundSendsAsync ( long id )
137143 {
138- _streamClosedFeature . OnClosed ( static state =>
139- {
140- var stream = ( Http3ControlStream ) state ! ;
141- stream . OnStreamClosed ( ) ;
142- } , this ) ;
143-
144144 await _frameWriter . WriteStreamIdAsync ( id ) ;
145145 await _frameWriter . WriteSettingsAsync ( _serverPeerSettings . GetNonProtocolDefaults ( ) ) ;
146146 }
@@ -311,18 +311,13 @@ private async Task HandleControlStream()
311311 }
312312 }
313313
314- private async ValueTask HandleEncodingDecodingTask ( )
314+ private Task HandleEncodingDecodingTask ( )
315315 {
316316 // Noop encoding and decoding task. Settings make it so we don't need to read content of encoder and decoder.
317317 // An endpoint MUST allow its peer to create an encoder stream and a
318318 // decoder stream even if the connection's settings prevent their use.
319319
320- while ( _isClosed == 0 )
321- {
322- var result = await Input . ReadAsync ( ) ;
323- var readableBuffer = result . Buffer ;
324- Input . AdvanceTo ( readableBuffer . End ) ;
325- }
320+ return Input . CopyToAsync ( Stream . Null ) ;
326321 }
327322
328323 private ValueTask ProcessHttp3ControlStream ( Http3RawFrame incomingFrame , bool isContinuedFrame , in ReadOnlySequence < byte > payload , out SequencePosition consumed )
@@ -372,11 +367,6 @@ private ValueTask ProcessSettingsFrameAsync(bool isContinuedFrame, ReadOnlySeque
372367 }
373368
374369 _haveReceivedSettingsFrame = true ;
375- _streamClosedFeature . OnClosed ( static state =>
376- {
377- var stream = ( Http3ControlStream ) state ! ;
378- stream . OnStreamClosed ( ) ;
379- } , this ) ;
380370 }
381371
382372 while ( true )
0 commit comments