Fix race condition for creation of download operation when isCancelled is YES but isFinished is NO

Fix race condition for creation of download operation when isCancelled is YES but isFinished is NO

update comment
This commit is contained in:
zhongwuzw 2019-01-07 15:56:24 +08:00
parent c95be0994e
commit 6becff0f06
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 = ^{