File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -84,6 +84,7 @@ let package = Package(
8484 . product( name: " X509 " , package : " swift-certificates " ) ,
8585 . product( name: " SwiftTLS " , package : " swift-tls " ) ,
8686 . product( name: " SwiftNetwork " , package : " swift-network-evolution " ) ,
87+ . product( name: " DequeModule " , package : " swift-collections " ) ,
8788 . target( name: " ChildChannelMultiplexer " ) ,
8889 ] ,
8990 swiftSettings: swiftSettings
Original file line number Diff line number Diff line change @@ -434,28 +434,19 @@ extension QUICConnectionChildChannelStateMachine {
434434 private mutating func drainFinalizedOutputAndHandleLifecycle( into actions: inout Actions ) {
435435
436436 // Drain.
437- do {
438- self . logger. trace ( " QUICConnectionChildChannelStateMachine drainFinalizedOutputAndHandleLifecycle loop " )
439- var shouldFlush = false
440- while let buffer = try self . quicConnection. nextOutboundPacket ( ) {
441- actions. append (
442- . parentChannelWrite(
443- message: AddressedEnvelope ( remoteAddress: self . remoteAddress, data: buffer) ,
444- promise: nil
445- )
437+ self . logger. trace ( " QUICConnectionChildChannelStateMachine drainFinalizedOutputAndHandleLifecycle loop " )
438+ var shouldFlush = false
439+ while let buffer = self . quicConnection. nextOutboundPacket ( ) {
440+ actions. append (
441+ . parentChannelWrite(
442+ message: AddressedEnvelope ( remoteAddress: self . remoteAddress, data: buffer) ,
443+ promise: nil
446444 )
447- shouldFlush = true
448- }
449- if shouldFlush {
450- actions. append ( . childChannelFlush)
451- }
452- } catch {
453- self . logger. trace (
454- " QUICConnectionChildChannelStateMachine drainFinalizedOutputAndHandleLifecycle caught error " ,
455- metadata: [ " error " : " \( error) " ]
456445 )
457- let promise = self . close ( )
458- actions. append ( . childChannelEncounterError( error: error, promise: promise) )
446+ shouldFlush = true
447+ }
448+ if shouldFlush {
449+ actions. append ( . childChannelFlush)
459450 }
460451
461452 // Lifecycle.
Original file line number Diff line number Diff line change 1313//===----------------------------------------------------------------------===//
1414
1515import Crypto
16+ import DequeModule
1617import Logging
1718@_spi ( CustomByteBufferAllocator) import NIOCore
1819import NIOQUICHelpers
@@ -105,7 +106,7 @@ final class SwiftNetworkQUICConnection {
105106
106107 private var connectionStateMachine = QUICConnectionStateMachine ( )
107108
108- private var finalizedOutput : [ NIOCore . ByteBuffer ] = [ ]
109+ private var finalizedOutput : Deque < ByteBuffer > = [ ]
109110 private var inputPacketQueue : FrameArray = FrameArray ( capacity: 10 )
110111 private var newlyConnectedStreams : Set < QUICStreamID > = [ ]
111112 private var networkContext : NetworkContext
@@ -1126,11 +1127,8 @@ final class SwiftNetworkQUICConnection {
11261127 ///
11271128 @discardableResult
11281129 @inlinable
1129- func nextOutboundPacket( ) throws -> NIOCore . ByteBuffer ? {
1130- guard !self . finalizedOutput. isEmpty else {
1131- return nil
1132- }
1133- return self . finalizedOutput. removeFirst ( )
1130+ func nextOutboundPacket( ) -> ByteBuffer ? {
1131+ self . finalizedOutput. popFirst ( )
11341132 }
11351133
11361134 /// Returns stream IDs for newly connected streams.
You can’t perform that action at this time.
0 commit comments