Merge pull request #2574 from zhongwuzw/fix-operation-creation-race-condition

Fix race condition for creation of download operation when isCancelled is YES but isFinished is NO
This commit is contained in:
DreamPiggy 2019-01-08 15:01:34 +08:00 committed by GitHub
commit 60f4365420
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 2 deletions

View File

@ -289,8 +289,8 @@
LOCK(self.operationsLock);
NSOperation<SDWebImageDownloaderOperationInterface> *operation = [self.URLOperations objectForKey:url];
// There is a case that the operation may be marked as finished, but not been removed from `self.URLOperations`.
if (!operation || operation.isFinished) {
// There is a case that the operation may be marked as finished or cancelled, but not been removed from `self.URLOperations`.
if (!operation || operation.isFinished || operation.isCancelled) {
operation = [self createDownloaderOperationWithUrl:url options:options];
__weak typeof(self) wself = self;
operation.completionBlock = ^{