Skip to content

Commit

Permalink
Parallelize parse queue freezing, thanks steve
Browse files Browse the repository at this point in the history
This will counter db "deadlocks" where one account is starving another
and we try to freeze the starved one first.
  • Loading branch information
tmolitor-stud-tu committed Oct 27, 2023
1 parent ed1ae68 commit 46b72d8
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion Monal/NotificationService/NotificationService.m
Original file line number Diff line number Diff line change
Expand Up @@ -357,8 +357,19 @@ -(void) incomingIPC:(NSNotification*) notification
-(void) freezeAllParseQueues
{
DDLogInfo(@"Freezing all incoming streams until we know if we are either terminating or got another push");
dispatch_queue_t queue = dispatch_queue_create("im.monal.freezeAllParseQueues", DISPATCH_QUEUE_CONCURRENT);
for(xmpp* account in [MLXMPPManager sharedInstance].connectedXMPP)
[account freezeParseQueue];
{
//disconnect to prevent endless loops trying to connect
dispatch_async(queue, ^{
DDLogVerbose(@"freezeAllParseQueues: %@", account);
[account freezeParseQueue];
DDLogVerbose(@"freezeAllParseQueues: %@", account);
});
}
dispatch_barrier_sync(queue, ^{
DDLogVerbose(@"freezeAllParseQueues done (inside barrier)");
});
DDLogInfo(@"All parse queues frozen now");
}

Expand Down

0 comments on commit 46b72d8

Please sign in to comment.