Skip to content

Commit 620fcbb

Browse files
committed
Make urlSession delegate queue serial as per the spec.
1 parent 3ab67ad commit 620fcbb

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

Foundation/NSURLSession/NSURLSession.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,7 @@ open class URLSession : NSObject {
211211
self.workQueue = DispatchQueue(label: "URLSession<\(identifier)>")
212212
self.taskAttributesIsolation = DispatchQueue(label: "URLSession<\(identifier)>.taskAttributes", attributes: DispatchQueue.Attributes.concurrent)
213213
self.delegateQueue = OperationQueue()
214+
self.delegateQueue.maxConcurrentOperationCount = 1
214215
self.delegate = nil
215216
//TODO: Make sure this one can't be written to?
216217
// Could create a subclass of URLSessionConfiguration that wraps the
@@ -225,7 +226,9 @@ open class URLSession : NSObject {
225226
identifier = nextSessionIdentifier()
226227
self.workQueue = DispatchQueue(label: "URLSession<\(identifier)>")
227228
self.taskAttributesIsolation = DispatchQueue(label: "URLSession<\(identifier)>.taskAttributes", attributes: DispatchQueue.Attributes.concurrent)
228-
self.delegateQueue = queue ?? OperationQueue()
229+
let operationQueue = OperationQueue()
230+
operationQueue.maxConcurrentOperationCount = 1
231+
self.delegateQueue = queue ?? operationQueue
229232
self.delegate = delegate
230233
//TODO: Make sure this one can't be written to?
231234
// Could create a subclass of URLSessionConfiguration that wraps the

0 commit comments

Comments
 (0)