Authored by DreamPiggy
Committed by GitHub

Merge pull request #2346 from dreampiggy/fix_operation_race_condition

Fix that the downloader operation may not call the completion block in race condition
... ... @@ -275,7 +275,8 @@
LOCK(self.operationsLock);
SDWebImageDownloaderOperation *operation = [self.URLOperations objectForKey:url];
if (!operation) {
// There is a case that the operation may be marked as finished, but not been removed from `self.URLOperations`.
if (!operation || operation.isFinished) {
operation = createCallback();
__weak typeof(self) wself = self;
operation.completionBlock = ^{
... ...