Fix deadlock

pull/220/head
nielsandriesse 5 years ago
parent c0b4a548bf
commit fcf0910e51

@ -733,6 +733,12 @@ typedef enum : NSUInteger {
[self.headerView updateSubtitleForCurrentStatus]; [self.headerView updateSubtitleForCurrentStatus];
}); });
} }
if ([self.thread isKindOfClass:TSContactThread.class]) {
[LKStorage writeWithBlock:^(YapDatabaseReadWriteTransaction *transaction) {
[SSKEnvironment.shared.profileManager ensureProfileCachedForContactWithID:self.thread.contactIdentifier with:transaction];
}];
}
} }
- (void)createContents - (void)createContents

@ -165,10 +165,11 @@ public final class MultiDeviceProtocol : NSObject {
let recipient = SignalRecipient.getOrBuildUnsavedRecipient(forRecipientId: hexEncodedPublicKey, transaction: transaction) let recipient = SignalRecipient.getOrBuildUnsavedRecipient(forRecipientId: hexEncodedPublicKey, transaction: transaction)
let udManager = SSKEnvironment.shared.udManager let udManager = SSKEnvironment.shared.udManager
let senderCertificate = udManager.getSenderCertificate() let senderCertificate = udManager.getSenderCertificate()
SSKEnvironment.shared.profileManager.ensureProfileCachedForContact(withID: hexEncodedPublicKey, with: transaction) // Prevent the line below from starting a write transaction
let (promise, seal) = Promise<OWSMessageSend>.pending() let (promise, seal) = Promise<OWSMessageSend>.pending()
LokiAPI.workQueue.async {
var recipientUDAccess: OWSUDAccess? var recipientUDAccess: OWSUDAccess?
if let senderCertificate = senderCertificate { if let senderCertificate = senderCertificate {
SSKEnvironment.shared.profileManager.ensureProfileCachedForContact(withID: hexEncodedPublicKey, with: transaction) // Prevent the line below from starting a write transaction
recipientUDAccess = udManager.udAccess(forRecipientId: hexEncodedPublicKey, requireSyncAccess: true) recipientUDAccess = udManager.udAccess(forRecipientId: hexEncodedPublicKey, requireSyncAccess: true)
} }
let messageSend = OWSMessageSend(message: message, thread: thread, recipient: recipient, senderCertificate: senderCertificate, let messageSend = OWSMessageSend(message: message, thread: thread, recipient: recipient, senderCertificate: senderCertificate,
@ -178,6 +179,7 @@ public final class MultiDeviceProtocol : NSObject {
externalSeal?.reject(error) externalSeal?.reject(error)
}) })
seal.fulfill(messageSend) seal.fulfill(messageSend)
}
return promise return promise
} }

Loading…
Cancel
Save