mirror of
https://github.com/StikDebug/StikDebug.git
synced 2026-10-16 04:20:30 +00:00
fix: prevent stalled tunnel connections from exhausting threads
This commit is contained in:
parent
b3e3096b63
commit
b916fe51cc
4 changed files with 32 additions and 3 deletions
|
|
@ -188,7 +188,9 @@ final class JITEnableContext {
|
|||
tunnelLock.unlock()
|
||||
|
||||
if let waitSemaphore {
|
||||
waitSemaphore.wait()
|
||||
guard waitSemaphore.wait(timeout: .now() + .seconds(15)) == .success else {
|
||||
throw makeError("Timed out waiting for the tunnel connection", code: -19)
|
||||
}
|
||||
waitSemaphore.signal()
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -13,11 +13,29 @@ final class MountingProgress: ObservableObject {
|
|||
@Published private(set) var mountingThread: Thread?
|
||||
@Published private(set) var coolisMounted: Bool = false
|
||||
|
||||
private let mountCheckLock = NSLock()
|
||||
private var mountCheckInProgress = false
|
||||
|
||||
private init() {}
|
||||
|
||||
func checkforMounted() {
|
||||
guard TunnelManager.shared.isConnected else { return }
|
||||
|
||||
mountCheckLock.lock()
|
||||
guard !mountCheckInProgress else {
|
||||
mountCheckLock.unlock()
|
||||
return
|
||||
}
|
||||
mountCheckInProgress = true
|
||||
mountCheckLock.unlock()
|
||||
|
||||
DispatchQueue.global(qos: .utility).async {
|
||||
let mounted = isMounted()
|
||||
|
||||
self.mountCheckLock.lock()
|
||||
self.mountCheckInProgress = false
|
||||
self.mountCheckLock.unlock()
|
||||
|
||||
DispatchQueue.main.async {
|
||||
self.coolisMounted = mounted
|
||||
}
|
||||
|
|
@ -32,6 +50,8 @@ final class MountingProgress: ObservableObject {
|
|||
}
|
||||
|
||||
func pubMount() {
|
||||
guard TunnelManager.shared.isConnected else { return }
|
||||
|
||||
DispatchQueue.global(qos: .utility).async { [weak self] in
|
||||
self?.mount()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,10 +20,15 @@ final class InstalledAppsViewModel: ObservableObject {
|
|||
private let cacheKeyDebuggable = "cachedDebuggableApps"
|
||||
private let cacheKeyNonDebuggable = "cachedNonDebuggableApps"
|
||||
private let cacheKeySystem = "cachedSystemApps"
|
||||
private var cancellables: Set<AnyCancellable> = []
|
||||
|
||||
init() {
|
||||
loadCachedApps()
|
||||
refreshAppLists()
|
||||
TunnelManager.shared.$isConnected
|
||||
.removeDuplicates()
|
||||
.filter { $0 }
|
||||
.sink { [weak self] _ in self?.refreshAppLists() }
|
||||
.store(in: &cancellables)
|
||||
}
|
||||
|
||||
func refreshAppLists() {
|
||||
|
|
|
|||
|
|
@ -83,7 +83,9 @@ struct InstalledAppsListView: View {
|
|||
handleLoadingChange(isLoading)
|
||||
}
|
||||
.onReceive(NotificationCenter.default.publisher(for: .pairingFileImported)) { _ in
|
||||
viewModel.refreshAppLists()
|
||||
if TunnelManager.shared.isConnected {
|
||||
viewModel.refreshAppLists()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue