Avoid YapDatabase deadlock in OWSMessageSender.

// FREEBIE
pull/1/head
Matthew Chen 9 years ago
parent 63cc0328b5
commit 607dd9a2f2

@ -862,9 +862,12 @@ NSString *const OWSMessageSenderRateLimitedException = @"RateLimitedException";
return;
}
// Getting the local number uses a transaction, so we need to do that before we
// create a new transaction to avoid deadlock.
NSString *contactId = [TSAccountManager localNumber];
[self.dbConnection readWriteWithBlock:^(YapDatabaseReadWriteTransaction *transaction) {
TSContactThread *cThread =
[TSContactThread getOrCreateThreadWithContactId:[TSAccountManager localNumber] transaction:transaction];
[TSContactThread getOrCreateThreadWithContactId:contactId transaction:transaction];
[cThread saveWithTransaction:transaction];
TSIncomingMessage *incomingMessage =
[[TSIncomingMessage alloc] initWithTimestamp:(outgoingMessage.timestamp + 1)

Loading…
Cancel
Save