fix: clear pending pings to avoid promise leaks on connection close/suspend
- Add cancel() method to RttCommand to fail promise on connection close - Add dequeueAll() method to ConcurrentQueue for batch cleanup - Call clearPendingPings() in close(), suspend(), and disconnect() methods - Prevents 'leaking promise' crash when connection is closed while pings are pending
This commit is contained in:
@@ -29,4 +29,13 @@ internal class ConcurrentQueue<T> {
|
||||
guard !elements.isEmpty else { return nil }
|
||||
return elements.removeFirst()
|
||||
}
|
||||
|
||||
/// Dequeue all elements at once (used for cleanup)
|
||||
func dequeueAll() -> [T] {
|
||||
lock.lock()
|
||||
defer { lock.unlock() }
|
||||
let all = elements
|
||||
elements.removeAll()
|
||||
return all
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user