Ensure that deleting sessions happens on session queue

// FREEBIE
pull/1/head
Michael Kirk 8 years ago
parent 2d93b8c6ec
commit bb38fce54e

@ -1,5 +1,6 @@
// Created by Frederic Jacobs on 31/12/14. //
// Copyright (c) 2014 Open Whisper Systems. All rights reserved. // Copyright (c) 2017 Open Whisper Systems. All rights reserved.
//
#import "TSInvalidIdentityKeyReceivingErrorMessage.h" #import "TSInvalidIdentityKeyReceivingErrorMessage.h"
#import "OWSFingerprint.h" #import "OWSFingerprint.h"
@ -78,8 +79,11 @@ NS_ASSUME_NONNULL_BEGIN
return; return;
} }
// Saving a new identity mutates the session store so it must happen on the sessionStoreQueue
dispatch_async([OWSDispatch sessionStoreQueue], ^{
[[TSStorageManager sharedManager] saveRemoteIdentity:newKey recipientId:self.envelope.source]; [[TSStorageManager sharedManager] saveRemoteIdentity:newKey recipientId:self.envelope.source];
dispatch_async(dispatch_get_main_queue(), ^{
// Decrypt this and any old messages for the newly accepted key // Decrypt this and any old messages for the newly accepted key
NSArray<TSInvalidIdentityKeyReceivingErrorMessage *> *messagesToDecrypt = NSArray<TSInvalidIdentityKeyReceivingErrorMessage *> *messagesToDecrypt =
[self.thread receivedMessagesForInvalidKey:newKey]; [self.thread receivedMessagesForInvalidKey:newKey];
@ -92,6 +96,8 @@ NS_ASSUME_NONNULL_BEGIN
// 2.) fail and create a new identical error message in the thread. // 2.) fail and create a new identical error message in the thread.
[errorMessage remove]; [errorMessage remove];
} }
});
});
} }
- (NSData *)newIdentityKey - (NSData *)newIdentityKey

@ -1,5 +1,6 @@
// Created by Frederic Jacobs on 15/02/15. //
// Copyright (c) 2015 Open Whisper Systems. All rights reserved. // Copyright (c) 2017 Open Whisper Systems. All rights reserved.
//
#import "TSInvalidIdentityKeySendingErrorMessage.h" #import "TSInvalidIdentityKeySendingErrorMessage.h"
#import "OWSFingerprint.h" #import "OWSFingerprint.h"
@ -56,7 +57,10 @@ NSString *TSInvalidRecipientKey = @"TSInvalidRecipientKey";
- (void)acceptNewIdentityKey - (void)acceptNewIdentityKey
{ {
// Saving a new identity mutates the session store so it must happen on the sessionStoreQueue
dispatch_async([OWSDispatch sessionStoreQueue], ^{
[[TSStorageManager sharedManager] saveRemoteIdentity:self.newIdentityKey recipientId:self.recipientId]; [[TSStorageManager sharedManager] saveRemoteIdentity:self.newIdentityKey recipientId:self.recipientId];
});
} }
- (NSData *)newIdentityKey - (NSData *)newIdentityKey

@ -581,7 +581,9 @@ NS_ASSUME_NONNULL_BEGIN
} }
}]; }];
dispatch_async([OWSDispatch sessionStoreQueue], ^{
[[TSStorageManager sharedManager] deleteAllSessionsForContact:endSessionEnvelope.source]; [[TSStorageManager sharedManager] deleteAllSessionsForContact:endSessionEnvelope.source];
});
} }
- (void)handleExpirationTimerUpdateMessageWithEnvelope:(OWSSignalServiceProtosEnvelope *)envelope - (void)handleExpirationTimerUpdateMessageWithEnvelope:(OWSSignalServiceProtosEnvelope *)envelope

Loading…
Cancel
Save