From 235ba021ad7847f0f18b2dee9364419d03f6ed1e Mon Sep 17 00:00:00 2001 From: agnosticdev Date: Wed, 16 Sep 2026 08:39:49 -0700 Subject: [PATCH 1/3] SwiftQUIC: Fix off-queue scheduled event --- Sources/SwiftNetwork/QUIC/FlowControl.swift | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Sources/SwiftNetwork/QUIC/FlowControl.swift b/Sources/SwiftNetwork/QUIC/FlowControl.swift index 5369712f..ffcffbec 100644 --- a/Sources/SwiftNetwork/QUIC/FlowControl.swift +++ b/Sources/SwiftNetwork/QUIC/FlowControl.swift @@ -403,7 +403,9 @@ extension QUICStreamInstance { if self.maximumStreamDataSize == 0 { updateOutboundFlowControlCredit(connection: connection) if self.maximumStreamDataSize > 0 { - upper.deliverOutboundRoomAvailableEvent(reference) + fromExternal { + upper.deliverOutboundRoomAvailableEvent(reference) + } } } } From 7d5abc093765931472e55080732a297ba184192a Mon Sep 17 00:00:00 2001 From: agnosticdev Date: Wed, 16 Sep 2026 10:51:29 -0700 Subject: [PATCH 2/3] Move to the instance async function --- Sources/SwiftNetwork/QUIC/FlowControl.swift | 4 +--- Sources/SwiftNetwork/QUIC/QUICConnection.swift | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/Sources/SwiftNetwork/QUIC/FlowControl.swift b/Sources/SwiftNetwork/QUIC/FlowControl.swift index ffcffbec..5369712f 100644 --- a/Sources/SwiftNetwork/QUIC/FlowControl.swift +++ b/Sources/SwiftNetwork/QUIC/FlowControl.swift @@ -403,9 +403,7 @@ extension QUICStreamInstance { if self.maximumStreamDataSize == 0 { updateOutboundFlowControlCredit(connection: connection) if self.maximumStreamDataSize > 0 { - fromExternal { - upper.deliverOutboundRoomAvailableEvent(reference) - } + upper.deliverOutboundRoomAvailableEvent(reference) } } } diff --git a/Sources/SwiftNetwork/QUIC/QUICConnection.swift b/Sources/SwiftNetwork/QUIC/QUICConnection.swift index 14eb1adf..eb5d51cc 100644 --- a/Sources/SwiftNetwork/QUIC/QUICConnection.swift +++ b/Sources/SwiftNetwork/QUIC/QUICConnection.swift @@ -5571,7 +5571,7 @@ extension QUICConnection { } asyncSendRunning = true log.datapath("async: scheduling restart after packet burst") - self.context.async { + self.async { self.resumeSendingAfterBurstLimit() } } From fc8ecd1bc91ce878f951444939539ee42d8f3018 Mon Sep 17 00:00:00 2001 From: agnosticdev Date: Wed, 16 Sep 2026 11:11:07 -0700 Subject: [PATCH 3/3] Switch QLog to write with instance async --- Sources/SwiftNetwork/QUIC/QUICConnection.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/SwiftNetwork/QUIC/QUICConnection.swift b/Sources/SwiftNetwork/QUIC/QUICConnection.swift index eb5d51cc..55ecde96 100644 --- a/Sources/SwiftNetwork/QUIC/QUICConnection.swift +++ b/Sources/SwiftNetwork/QUIC/QUICConnection.swift @@ -4333,7 +4333,7 @@ public final class QUICConnection: ManyToManyApplicationStreamProtocol, else { return } - context.async { + self.async { var flowType: QLogFlowType = .client var applicationType = "client" if self.isServer {