fix quicClient

This commit is contained in:
anlicheng 2026-04-28 17:19:55 +08:00
parent 7b549981af
commit 2b234fb5c3
2 changed files with 82 additions and 71 deletions

View File

@ -268,6 +268,7 @@ actor SDLContextActor {
await quicClient.start()
do {
try await quicClient.waitReady(timeout: .seconds(3))
// quic
try await Task.sleep(for: .seconds(0.3))
@ -286,6 +287,9 @@ actor SDLContextActor {
}
await self.handleQUICMessage(message: message)
}
if Task.isCancelled {
return
}
throw SDLQUICClientExit.transportClosed("messageStream finished")
}
@ -316,9 +320,19 @@ actor SDLContextActor {
throw error
}
}
if Task.isCancelled {
return
}
throw SDLQUICClientExit.transportClosed("eventStream finished")
}
do {
let _ = try await group.next()
await quicClient.stop()
} catch {
await quicClient.stop()
throw error
}
}
} onCancel: {
@ -326,6 +340,10 @@ actor SDLContextActor {
await quicClient.stop()
}
}
} catch {
await quicClient.stop()
throw error
}
}
private func handleQUICMessage(message: SDLQUICInboundMessage) async {

View File

@ -136,7 +136,6 @@ actor SDLQUICClient {
}
func run() async -> SDLQUICClientExit {
await withTaskCancellationHandler {
await withTaskGroup(of: SDLQUICClientExit.self) { group in
group.addTask {
await self.readLoop()
@ -148,16 +147,10 @@ actor SDLQUICClient {
let exit = await group.next() ?? .normal
group.cancelAll()
await self.stop()
self.finishStreams()
return exit
}
} onCancel: {
Task {
await self.stop()
}
}
}
func send(type: SDLPacketType, data: Data) {