Rework thread safety in profile manager.

This commit is contained in:
Matthew Chen 2017-12-08 13:27:53 -05:00
parent 911c4d380b
commit ee300590e3
1 changed files with 4 additions and 4 deletions

View File

@ -845,7 +845,7 @@ const NSUInteger kOWSProfileManager_MaxAvatarDiameter = 640;
NSString *fileName = [[NSUUID UUID].UUIDString stringByAppendingPathExtension:@"jpg"];
NSString *filePath = [self.profileAvatarsDirPath stringByAppendingPathComponent:fileName];
@synchronized(self)
@synchronized(self.currentAvatarDownloads)
{
if ([self.currentAvatarDownloads containsObject:userProfile.recipientId]) {
// Download already in flight; ignore.
@ -871,7 +871,7 @@ const NSUInteger kOWSProfileManager_MaxAvatarDiameter = 640;
}
}
@synchronized(self)
@synchronized(self.currentAvatarDownloads)
{
[self.currentAvatarDownloads removeObject:userProfile.recipientId];
}
@ -1153,7 +1153,7 @@ const NSUInteger kOWSProfileManager_MaxAvatarDiameter = 640;
}
UIImage *_Nullable image = nil;
@synchronized(self)
@synchronized(self.profileAvatarImageCache)
{
image = [self.profileAvatarImageCache objectForKey:filename];
}
@ -1175,7 +1175,7 @@ const NSUInteger kOWSProfileManager_MaxAvatarDiameter = 640;
OWSAssert(filename.length > 0);
OWSAssert(image);
@synchronized(self)
@synchronized(self.profileAvatarImageCache)
{
if (image) {
[self.profileAvatarImageCache setObject:image forKey:filename];