File tree Expand file tree Collapse file tree 1 file changed +9
-17
lines changed
src/Servers/Kestrel/Core/src/Internal/Http2 Expand file tree Collapse file tree 1 file changed +9
-17
lines changed Original file line number Diff line number Diff line change @@ -668,21 +668,6 @@ private Http2StreamContext CreateHttp2StreamContext()
668668 return streamContext ;
669669 }
670670
671- private void ReturnStream ( Http2Stream stream )
672- {
673- // We're conservative about what streams we can reuse.
674- // If there is a chance the stream is still in use then don't attempt to reuse it.
675- Debug . Assert ( stream . CanReuse ) ;
676-
677- if ( StreamPool . Count < MaxStreamPoolSize )
678- {
679- // This property is used to remove unused streams from the pool
680- stream . DrainExpirationTicks = SystemClock . UtcNowTicks + StreamPoolExpiryTicks ;
681-
682- StreamPool . Push ( stream ) ;
683- }
684- }
685-
686671 private Task ProcessPriorityFrameAsync ( )
687672 {
688673 if ( _currentHeadersStream != null )
@@ -1181,12 +1166,19 @@ private void UpdateCompletedStreams()
11811166 private void RemoveStream ( Http2Stream stream )
11821167 {
11831168 _streams . Remove ( stream . StreamId ) ;
1184- if ( stream . CanReuse )
1169+
1170+ if ( stream . CanReuse && StreamPool . Count < MaxStreamPoolSize )
11851171 {
1186- ReturnStream ( stream ) ;
1172+ // Pool and reuse the stream if it finished in a graceful state and there is space in the pool.
1173+
1174+ // This property is used to remove unused streams from the pool
1175+ stream . DrainExpirationTicks = SystemClock . UtcNowTicks + StreamPoolExpiryTicks ;
1176+
1177+ StreamPool . Push ( stream ) ;
11871178 }
11881179 else
11891180 {
1181+ // Stream didn't complete gracefully or pool is full.
11901182 stream . Dispose ( ) ;
11911183 }
11921184 }
You can’t perform that action at this time.
0 commit comments