mirror of
https://github.com/SideStore/SideStore.git
synced 2026-02-09 06:43:25 +01:00
[AltServer] Replaces lock with semaphore when updating app groups
Locks can’t be unlocked from a separate thread than they were locked on…whoops.
This commit is contained in:
@@ -10,7 +10,7 @@ import Cocoa
|
|||||||
import UserNotifications
|
import UserNotifications
|
||||||
import ObjectiveC
|
import ObjectiveC
|
||||||
|
|
||||||
private let appGroupsLock = NSLock()
|
private let appGroupsSemaphore = DispatchSemaphore(value: 1)
|
||||||
|
|
||||||
private let developerDiskManager = DeveloperDiskManager()
|
private let developerDiskManager = DeveloperDiskManager()
|
||||||
|
|
||||||
@@ -680,16 +680,16 @@ private extension ALTDeviceManager
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Dispatch onto global queue to prevent appGroupsLock deadlock.
|
// Dispatch onto global queue to prevent appGroupsSemaphore deadlock.
|
||||||
DispatchQueue.global().async {
|
DispatchQueue.global().async {
|
||||||
|
|
||||||
// Ensure we're not concurrently fetching and updating app groups,
|
// Ensure we're not concurrently fetching and updating app groups,
|
||||||
// which can lead to race conditions such as adding an app group twice.
|
// which can lead to race conditions such as adding an app group twice.
|
||||||
appGroupsLock.lock()
|
appGroupsSemaphore.wait()
|
||||||
|
|
||||||
func finish(_ result: Result<ALTAppID, Error>)
|
func finish(_ result: Result<ALTAppID, Error>)
|
||||||
{
|
{
|
||||||
appGroupsLock.unlock()
|
appGroupsSemaphore.signal()
|
||||||
completionHandler(result)
|
completionHandler(result)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user