fix quicClient
This commit is contained in:
parent
7b549981af
commit
2b234fb5c3
@ -268,12 +268,13 @@ actor SDLContextActor {
|
||||
|
||||
await quicClient.start()
|
||||
|
||||
do {
|
||||
try await quicClient.waitReady(timeout: .seconds(3))
|
||||
// 这里必须等待quic的协商完成
|
||||
try await Task.sleep(for: .seconds(0.3))
|
||||
SDLLogger.log("[SDLContext] start quic client: \(self.config.serverHost)")
|
||||
|
||||
try await withTaskCancellationHandler{
|
||||
try await withTaskCancellationHandler {
|
||||
try await withThrowingTaskGroup { group in
|
||||
defer {
|
||||
group.cancelAll()
|
||||
@ -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 {
|
||||
|
||||
@ -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) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user