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,19 +165,21 @@ 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()
var recipientUDAccess: OWSUDAccess? LokiAPI.workQueue.async {
if let senderCertificate = senderCertificate { var recipientUDAccess: OWSUDAccess?
SSKEnvironment.shared.profileManager.ensureProfileCachedForContact(withID: hexEncodedPublicKey, with: transaction) // Prevent the line below from starting a write transaction if let senderCertificate = senderCertificate {
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,
udAccess: recipientUDAccess, localNumber: getUserHexEncodedPublicKey(), success: {
externalSeal?.fulfill(())
}, failure: { error in
externalSeal?.reject(error)
})
seal.fulfill(messageSend)
} }
let messageSend = OWSMessageSend(message: message, thread: thread, recipient: recipient, senderCertificate: senderCertificate,
udAccess: recipientUDAccess, localNumber: getUserHexEncodedPublicKey(), success: {
externalSeal?.fulfill(())
}, failure: { error in
externalSeal?.reject(error)
})
seal.fulfill(messageSend)
return promise return promise
} }

Loading…
Cancel
Save