Skip to content

Commit 9f4d149

Browse files
committed
Revert "fix: not multithread safe access to cancel var"
This reverts commit 3184f84.
1 parent 3184f84 commit 9f4d149

File tree

1 file changed

+9
-18
lines changed

1 file changed

+9
-18
lines changed

LaunchDarkly/LaunchDarkly/LDClient.swift

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -385,29 +385,20 @@ public class LDClient {
385385
os_log("%s LDClient.identify was called with a timeout greater than %f seconds. We recommend a timeout of less than %f seconds.", log: config.logger, type: .info, self.typeName(and: #function), LDClient.longTimeoutInterval, LDClient.longTimeoutInterval)
386386
}
387387

388-
// Use a thread-safe way to handle cancellation/completion state
389-
let completionQueue = DispatchQueue(label: "com.launchdarkly.ldclient.identify-completion", attributes: .concurrent)
390-
var completed = false
391-
392-
let finish: (IdentifyResult) -> Void = { result in
393-
var shouldCall = false
394-
completionQueue.sync(flags: .barrier) {
395-
if !completed {
396-
completed = true
397-
shouldCall = true
398-
}
399-
}
400-
if shouldCall {
401-
completion(result)
402-
}
403-
}
388+
var cancel = false
404389

405390
DispatchQueue.global().asyncAfter(deadline: .now() + timeout) {
406-
finish(.timeout)
391+
guard !cancel else { return }
392+
393+
cancel = true
394+
completion(.timeout)
407395
}
408396

409397
identify(context: context, useCache: useCache) { result in
410-
finish(result)
398+
guard !cancel else { return }
399+
400+
cancel = true
401+
completion(result)
411402
}
412403
}
413404

0 commit comments

Comments
 (0)