Merge branch 'mkirk/crash-on-first-message'

pull/1/head
Michael Kirk 7 years ago
commit b358a75e3e

@ -154,11 +154,13 @@ NSString *const kNSNotificationName_IdentityStateDidChange = @"kNSNotificationNa
return identityKeyPair; return identityKeyPair;
} }
// This method should only be called from SignalProtocolKit, which doesn't know about YapDatabaseTransactions.
// Whenever possible, prefer to call the strongly typed variant: `identityKeyPairWithTransaction:`.
- (nullable ECKeyPair *)identityKeyPair:(nullable id)protocolContext - (nullable ECKeyPair *)identityKeyPair:(nullable id)protocolContext
{ {
OWSAssert([protocolContext isKindOfClass:[YapDatabaseReadWriteTransaction class]]); OWSAssert([protocolContext isKindOfClass:[YapDatabaseReadTransaction class]]);
YapDatabaseReadWriteTransaction *transaction = protocolContext; YapDatabaseReadTransaction *transaction = protocolContext;
return [self identityKeyPairWithTransaction:transaction]; return [self identityKeyPairWithTransaction:transaction];
} }
@ -449,7 +451,7 @@ NSString *const kNSNotificationName_IdentityStateDidChange = @"kNSNotificationNa
OWSAssert(transaction); OWSAssert(transaction);
if ([[TSAccountManager localNumber] isEqualToString:recipientId]) { if ([[TSAccountManager localNumber] isEqualToString:recipientId]) {
ECKeyPair *_Nullable localIdentityKeyPair = [self identityKeyPair:transaction]; ECKeyPair *_Nullable localIdentityKeyPair = [self identityKeyPairWithTransaction:transaction];
if ([localIdentityKeyPair.publicKey isEqualToData:identityKey]) { if ([localIdentityKeyPair.publicKey isEqualToData:identityKey]) {
return YES; return YES;

@ -1328,6 +1328,8 @@ NSString *const OWSMessageSenderRateLimitedException = @"RateLimitedException";
} }
dispatch_semaphore_signal(sema); dispatch_semaphore_signal(sema);
}]; }];
// FIXME: Currently this happens within a readwrite transaction - meaning our read-write transaction blocks
// on a network request.
dispatch_semaphore_wait(sema, DISPATCH_TIME_FOREVER); dispatch_semaphore_wait(sema, DISPATCH_TIME_FOREVER);
if (exception) { if (exception) {
@throw exception; @throw exception;

Loading…
Cancel
Save