Rework flush of registration connection(s).

pull/1/head
Matthew Chen 7 years ago
parent e1138df771
commit a264268253

@ -136,31 +136,23 @@ void runAsyncRegistrationsForStorage(OWSStorage *storage)
DDLogVerbose(@"%@ async registrations enqueued.", self.logTag); DDLogVerbose(@"%@ async registrations enqueued.", self.logTag);
// Flush the write queue to ensure all async registrations have begun. // Use an empty read/write transaction to to ensure all async registrations have completed.
[[self newDatabaseConnection] [[self newDatabaseConnection] asyncReadWriteWithBlock:^(YapDatabaseReadWriteTransaction *transaction) {
flushTransactionsWithCompletionQueue:dispatch_get_main_queue() // Do nothing.
completionBlock:^{ //
// Block until all async registrations are complete. // We can't use flushTransactionsWithCompletionQueue because it
// // doesn't flush the YapDatabase.writeQueue.
// NOTE: This has to happen on the "registration connections" for this }
// database. completionQueue:dispatch_get_main_queue()
completionBlock:^{
OWSAssert(!self.areAsyncRegistrationsComplete); OWSAssert(!self.areAsyncRegistrationsComplete);
[pendingRegistrationConnectionSet removeObject:dbConnection]; DDLogVerbose(@"%@ async registrations complete.", self.logTag);
if (pendingRegistrationConnectionSet.count > 0) {
DDLogVerbose(@"%@ registration " self.areAsyncRegistrationsComplete = YES;
@"connection flushed.",
self.logTag); completion();
return; }];
}
DDLogVerbose(@"%@ async registrations complete.", self.logTag);
self.areAsyncRegistrationsComplete = YES;
completion();
}];
} }
+ (void)protectFiles + (void)protectFiles

Loading…
Cancel
Save