fix udpHole
This commit is contained in:
parent
e07c81567a
commit
a728fd5408
@ -1,7 +1,7 @@
|
||||
//
|
||||
// SDLUDPHoleHandler.swift
|
||||
// punchnet
|
||||
//
|
||||
// 上游的SDLUDPHole是基于actor实现的,串行实现的逻辑已经保证了SDLUDPHoleHandler的内部的一致性
|
||||
// Created by 安礼成 on 2026/5/22.
|
||||
//
|
||||
import Foundation
|
||||
@ -23,9 +23,6 @@ final class SDLUDPHoleHandler: ChannelInboundHandler {
|
||||
public let messageStream: AsyncThrowingStream<SDLHoleDatagram, Error>
|
||||
private let messageContinuation: AsyncThrowingStream<SDLHoleDatagram, Error>.Continuation
|
||||
|
||||
private let locker = NSLock()
|
||||
private var isStopped: Bool = false
|
||||
|
||||
// 启动函数
|
||||
init() throws {
|
||||
let (stream, continuation) = AsyncThrowingStream.makeStream(of: SDLHoleDatagram.self, bufferingPolicy: .bufferingNewest(2048))
|
||||
@ -102,16 +99,6 @@ final class SDLUDPHoleHandler: ChannelInboundHandler {
|
||||
}
|
||||
|
||||
func stop() {
|
||||
locker.lock()
|
||||
defer {
|
||||
locker.unlock()
|
||||
}
|
||||
|
||||
guard !self.isStopped else {
|
||||
return
|
||||
}
|
||||
self.isStopped = true
|
||||
|
||||
self.messageContinuation.finish()
|
||||
let channel = self.channel
|
||||
self.channel = nil
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user