Fix that the downloader operation may not call the completion block in race cond…
…ition, which the operation we get is finished but not been removed from the operation array.
Showing
1 changed file
with
2 additions
and
1 deletions
@@ -275,7 +275,8 @@ | @@ -275,7 +275,8 @@ | ||
275 | 275 | ||
276 | LOCK(self.operationsLock); | 276 | LOCK(self.operationsLock); |
277 | SDWebImageDownloaderOperation *operation = [self.URLOperations objectForKey:url]; | 277 | SDWebImageDownloaderOperation *operation = [self.URLOperations objectForKey:url]; |
278 | - if (!operation) { | 278 | + // There is a case that the operation may be marked as finished, but not been removed from `self.URLOperations`. |
279 | + if (!operation || operation.isFinished) { | ||
279 | operation = createCallback(); | 280 | operation = createCallback(); |
280 | __weak typeof(self) wself = self; | 281 | __weak typeof(self) wself = self; |
281 | operation.completionBlock = ^{ | 282 | operation.completionBlock = ^{ |
-
Please register or login to post a comment