Skip to content

Commit

Permalink
Cleanup app suspension/resume process for serializable promises
Browse files Browse the repository at this point in the history
  • Loading branch information
tmolitor-stud-tu committed Dec 6, 2024
1 parent 648b8b8 commit a295b4a
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 6 deletions.
8 changes: 6 additions & 2 deletions Monal/Classes/HelperTools.m
Original file line number Diff line number Diff line change
Expand Up @@ -2101,10 +2101,11 @@ +(void) signalSuspension
[HelperTools flushLogsWithTimeout:0.100];
dispatch_suspend([DDLog loggingQueue]);
_suspensionHandlingIsSuspended = YES;

DDLogVerbose(@"Posting kMonalFrozen notification now...");
[[NSNotificationCenter defaultCenter] postNotificationName:kMonalFrozen object:nil];
}
}
DDLogVerbose(@"Posting kMonalIsFreezed notification now...");
[[NSNotificationCenter defaultCenter] postNotificationName:kMonalIsFreezed object:nil];
}

+(void) signalResumption
Expand All @@ -2115,6 +2116,9 @@ +(void) signalResumption
DDLogVerbose(@"Resuming logger queue...");
dispatch_resume([DDLog loggingQueue]);
_suspensionHandlingIsSuspended = NO;

DDLogVerbose(@"Posting kMonalUnfrozen notification now...");
[[NSNotificationCenter defaultCenter] postNotificationName:kMonalUnfrozen object:nil];
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion Monal/Classes/MLConstants.h
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,8 @@ static inline NSString* _Nonnull LocalizationNotNeeded(NSString* _Nonnull s)
#define kMonalIncomingSDP @"kMonalIncomingSDP"
#define kMonalIncomingICECandidate @"kMonalIncomingICECandidate"
#define kMonalWillBeFreezed @"kMonalWillBeFreezed"
#define kMonalIsFreezed @"kMonalIsFreezed"
#define kMonalFrozen @"kMonalFrozen"
#define kMonalUnfrozen @"kMonalUnfrozen"
#define kMonalNewMessageNotice @"kMonalNewMessageNotice"
#define kMonalMucSubjectChanged @"kMonalMucSubjectChanged"
#define kMonalDeletedMessageNotice @"kMonalDeletedMessageNotice"
Expand Down
2 changes: 1 addition & 1 deletion Monal/Classes/MLProcessLock.m
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ +(void) lock
lock = flock(_ownLockFD, LOCK_EX | LOCK_NB);
if(lock != 0)
@throw [NSException exceptionWithName:@"LockingError" reason:[NSString stringWithFormat:@"flock returned: %d (%d) on file: %s", lock, errno, _ownLockPath] userInfo:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(unlock) name:kMonalIsFreezed object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(unlock) name:kMonalFrozen object:nil];
}
}

Expand Down
7 changes: 5 additions & 2 deletions Monal/NotificationService/NotificationService.m
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ -(void) killAppex
[NotificationService setAppexCleanShutdownStatus:YES];

DDLogInfo(@"Now killing appex process, goodbye...");
[HelperTools flushLogsWithTimeout:0.100];
[HelperTools signalSuspension];
exit(0);
}

Expand Down Expand Up @@ -424,6 +424,9 @@ +(void) initialize

handlers = [NSMutableArray new];

//resume logging and other core tasks
[HelperTools signalResumption];

//init IPC
[IPC initializeForProcess:@"NotificationServiceExtension"];
[MLProcessLock initializeForProcess:@"NotificationServiceExtension"];
Expand Down Expand Up @@ -602,7 +605,7 @@ -(void) serviceExtensionTimeWillExpire
#endif

DDLogInfo(@"Committing suicide...");
[DDLog flushLog];
[HelperTools signalSuspension];
exit(0);

/*
Expand Down

0 comments on commit a295b4a

Please sign in to comment.