File tree Expand file tree Collapse file tree 1 file changed +6
-3
lines changed Expand file tree Collapse file tree 1 file changed +6
-3
lines changed Original file line number Diff line number Diff line change @@ -198,6 +198,7 @@ open class URLSession : NSObject {
198
198
/// - Note: It's a **concurrent** queue.
199
199
internal let taskAttributesIsolation : DispatchQueue
200
200
internal let taskRegistry = URLSession . _TaskRegistry ( )
201
+ fileprivate let identifierLock = NSLock ( )
201
202
fileprivate let identifier : Int32
202
203
fileprivate var invalidated = false
203
204
fileprivate static let registerProtocols : ( ) = {
@@ -406,9 +407,11 @@ extension URLSession._Request {
406
407
407
408
fileprivate extension URLSession {
408
409
func createNextTaskIdentifier( ) -> Int {
409
- let i = nextTaskIdentifier
410
- nextTaskIdentifier += 1
411
- return i
410
+ return identifierLock. synchronized {
411
+ let i = nextTaskIdentifier
412
+ nextTaskIdentifier += 1
413
+ return i
414
+ }
412
415
}
413
416
}
414
417
You can’t perform that action at this time.
0 commit comments