diff --git a/SoftU2F b/SoftU2F index c70e796..8343a82 160000 --- a/SoftU2F +++ b/SoftU2F @@ -1 +1 @@ -Subproject commit c70e796dffc4d2a86052afa313f06eb14bbfc976 +Subproject commit 8343a82cd4fc057c873f8ade3d36e7f7fff863b8 diff --git a/SoftU2FTool/UserPresence.swift b/SoftU2FTool/UserPresence.swift index ad43493..cc2637c 100644 --- a/SoftU2FTool/UserPresence.swift +++ b/SoftU2FTool/UserPresence.swift @@ -17,9 +17,25 @@ class UserPresence: NSObject { typealias Callback = (_ success: Bool) -> Void - static var current: UserPresence? static var skip = false + // Hacks to avoid a race between reads/writes to current. + static let currentAccessQueue = DispatchQueue(label: "currentAccessQueue") + static var _current: UserPresence? + static var current: UserPresence? { + get { + return currentAccessQueue.sync { + return _current + } + } + + set(newValue) { + currentAccessQueue.sync { + _current = newValue + } + } + } + // Display a notification, wait for the user to click it, and call the callback with `true`. // Calls callback with `false` if another test is done while we're waiting for this one. static func test(_ type: Notification, with callback: @escaping Callback) {