Skip to content

Commit

Permalink
Merge pull request #1537 from Statsminizzle/bugfix/cancel_crash
Browse files Browse the repository at this point in the history
Cancel moved to avoid crash
  • Loading branch information
onevcat authored Sep 29, 2020
2 parents e7f7599 + 96ed421 commit 9321758
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 3 deletions.
3 changes: 0 additions & 3 deletions Sources/Networking/SessionDataTask.swift
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,6 @@ public class SessionDataTask {
guard let callback = removeCallback(token) else {
return
}
if callbacksStore.count == 0 {
task.cancel()
}
onCallbackCancelled.call((token, callback))
}

Expand Down
1 change: 1 addition & 0 deletions Sources/Networking/SessionDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ class SessionDelegate: NSObject {
// No other callbacks waiting, we can clear the task now.
if !task.containsCallbacks {
let dataTask = task.task
dataTask.cancel()
self.remove(dataTask)
}
}
Expand Down

0 comments on commit 9321758

Please sign in to comment.