From df486cff6d10aa3b0c7e5db6063b9a30ecb14462 Mon Sep 17 00:00:00 2001 From: Thilo Molitor Date: Sun, 1 Dec 2024 01:32:06 +0100 Subject: [PATCH] Fix race condition in new suspension handling --- Monal/Classes/HelperTools.m | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/Monal/Classes/HelperTools.m b/Monal/Classes/HelperTools.m index 779f03514..783deaaea 100644 --- a/Monal/Classes/HelperTools.m +++ b/Monal/Classes/HelperTools.m @@ -1880,11 +1880,14 @@ +(void) flushLogsWithTimeout:(double) timeout +(void) signalSuspension { - DDLogVerbose(@"Suspending logger queue..."); - [HelperTools flushLogsWithTimeout:0.100]; @synchronized(_suspensionHandlingLock) { - dispatch_suspend([DDLog loggingQueue]); - _suspensionHandlingIsSuspended = YES; + if(!_suspensionHandlingIsSuspended) + { + DDLogVerbose(@"Suspending logger queue..."); + [HelperTools flushLogsWithTimeout:0.100]; + dispatch_suspend([DDLog loggingQueue]); + _suspensionHandlingIsSuspended = YES; + } } DDLogVerbose(@"Posting kMonalIsFreezed notification now..."); [[NSNotificationCenter defaultCenter] postNotificationName:kMonalIsFreezed object:nil];