From 4ce3547c7cba9f1479d64be84d1c7ad3f1d01a5b Mon Sep 17 00:00:00 2001 From: anlicheng <244108715@qq.com> Date: Fri, 22 May 2026 15:51:59 +0800 Subject: [PATCH] fix SuperClient --- Tun/Super/SDLSuperClient.swift | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Tun/Super/SDLSuperClient.swift b/Tun/Super/SDLSuperClient.swift index 8a88bfb..205dac6 100644 --- a/Tun/Super/SDLSuperClient.swift +++ b/Tun/Super/SDLSuperClient.swift @@ -17,8 +17,6 @@ actor SDLSuperClient { private var state: State = .idle - private let frameParser: SDLSuperFrameParser - private let queue = DispatchQueue(label: "com.sdl.SuperClient.queue") // 专用队列保证线程安全 // 数据流 @@ -29,9 +27,10 @@ actor SDLSuperClient { private var readTask: Task? private let connection: NWConnection + private let maxBufferSize: Int init(serverEndpoint: SDLConfiguration.ResolvedServerEndpoint, port: UInt16, maxBufferSize: Int = 2 * 1024 * 1024) { - self.frameParser = SDLSuperFrameParser(maxBufferSize: maxBufferSize) + self.maxBufferSize = maxBufferSize let pairs = AsyncThrowingStream.makeStream(of: SDLQUICInboundMessage.self) self.messageStream = pairs.stream @@ -117,11 +116,12 @@ actor SDLSuperClient { self.readTask?.cancel() self.readTask = Task { + let frameParser = SDLSuperFrameParser(maxBufferSize: self.maxBufferSize) do { while true { try Task.checkCancellation() let data = try await Self.readOnce(connection: self.connection) - let frames = try self.frameParser.parseFrames(data: data) + let frames = try frameParser.parseFrames(data: data) for frame in frames { try Task.checkCancellation() if let message = SDLSuperCodec.decode(frame: frame) {