Fix deadlock when responding to contacts sync messages.

pull/1/head
Matthew Chen 8 years ago
parent 93927801ee
commit 9b197fad03

@ -606,6 +606,13 @@ NS_ASSUME_NONNULL_BEGIN
} }
} else if (syncMessage.hasRequest) { } else if (syncMessage.hasRequest) {
if (syncMessage.request.type == OWSSignalServiceProtosSyncMessageRequestTypeContacts) { if (syncMessage.request.type == OWSSignalServiceProtosSyncMessageRequestTypeContacts) {
// We respond asynchronously because populating the sync message will
// create transactions and it's not practical (due to locking in the OWSIdentityManager)
// to plumb our transaction through.
//
// In rare cases this means we won't respond to the sync request, but that's
// acceptable.
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
OWSSyncContactsMessage *syncContactsMessage = OWSSyncContactsMessage *syncContactsMessage =
[[OWSSyncContactsMessage alloc] initWithSignalAccounts:self.contactsManager.signalAccounts [[OWSSyncContactsMessage alloc] initWithSignalAccounts:self.contactsManager.signalAccounts
identityManager:self.identityManager identityManager:self.identityManager
@ -619,8 +626,10 @@ NS_ASSUME_NONNULL_BEGIN
DDLogInfo(@"%@ Successfully sent Contacts response syncMessage.", self.logTag); DDLogInfo(@"%@ Successfully sent Contacts response syncMessage.", self.logTag);
} }
failure:^(NSError *error) { failure:^(NSError *error) {
DDLogError(@"%@ Failed to send Contacts response syncMessage with error: %@", self.logTag, error); DDLogError(
@"%@ Failed to send Contacts response syncMessage with error: %@", self.logTag, error);
}]; }];
});
} else if (syncMessage.request.type == OWSSignalServiceProtosSyncMessageRequestTypeGroups) { } else if (syncMessage.request.type == OWSSignalServiceProtosSyncMessageRequestTypeGroups) {
OWSSyncGroupsMessage *syncGroupsMessage = [[OWSSyncGroupsMessage alloc] init]; OWSSyncGroupsMessage *syncGroupsMessage = [[OWSSyncGroupsMessage alloc] init];
DataSource *dataSource = [DataSourceValue DataSource *dataSource = [DataSourceValue

Loading…
Cancel
Save