@@ -1412,8 +1412,8 @@ -(void) checkIfBackgroundTaskIsStillNeeded
14121412 [DDLog flushLog ];
14131413 DDLogVerbose (@" Setting _shutdownPending to YES..." );
14141414 _shutdownPending = YES ;
1415- [[MLXMPPManager sharedInstance ] disconnectAll ]; // disconnect all accounts to prevent TCP buffer leaking
14161415 [HelperTools scheduleBackgroundTask: NO ]; // request bg fetch execution in BGFETCH_DEFAULT_INTERVAL seconds
1416+ [[MLXMPPManager sharedInstance ] disconnectAll ]; // disconnect all accounts to prevent TCP buffer leaking
14171417 [HelperTools dispatchAsync: NO reentrantOnQueue: dispatch_get_main_queue () withBlock: ^{
14181418 BOOL stopped = NO ;
14191419 // make sure this will be done only once, even if we have an uikit bgtask and a bg fetch running simultaneously
@@ -1490,13 +1490,13 @@ -(void) addBackgroundTask
14901490 // this has to be before account disconnects, to detect which accounts are not idle (e.g. have a sync error)
14911491 [HelperTools updateSyncErrorsWithDeleteOnly: NO andWaitForCompletion: YES ];
14921492
1493- // disconnect all accounts to prevent TCP buffer leaking
1494- [[MLXMPPManager sharedInstance ] disconnectAll ];
1495-
14961493 // schedule a BGProcessingTaskRequest to process this further as soon as possible
14971494 // (if we end up here, the graceful shuttdown did not work out because we are not idle --> we need more cpu time)
14981495 [HelperTools scheduleBackgroundTask: YES ]; // force as soon as possible
14991496
1497+ // disconnect all accounts to prevent TCP buffer leaking
1498+ [[MLXMPPManager sharedInstance ] disconnectAll ];
1499+
15001500 // notify about pending app freeze (don't queue this notification because it should be handled IMMEDIATELY and INLINE)
15011501 DDLogVerbose (@" Posting kMonalWillBeFreezed notification now..." );
15021502 [[NSNotificationCenter defaultCenter ] postNotificationName: kMonalWillBeFreezed object: nil ];
@@ -1549,13 +1549,13 @@ -(void) handleBackgroundProcessingTask:(BGTask*) task
15491549 // this has to be before account disconnects, to detect which accounts are not idle (e.g. have a sync error)
15501550 [HelperTools updateSyncErrorsWithDeleteOnly: YES andWaitForCompletion: YES ];
15511551
1552- // disconnect all accounts to prevent TCP buffer leaking
1553- [[MLXMPPManager sharedInstance ] disconnectAll ];
1554-
15551552 // schedule a new BGProcessingTaskRequest to process this further as soon as possible
15561553 // (if we end up here, the graceful shuttdown did not work out because we are not idle --> we need more cpu time)
15571554 [HelperTools scheduleBackgroundTask: YES ]; // force as soon as possible
15581555
1556+ // disconnect all accounts to prevent TCP buffer leaking
1557+ [[MLXMPPManager sharedInstance ] disconnectAll ];
1558+
15591559 // notify about pending app freeze (don't queue this notification because it should be handled IMMEDIATELY and INLINE)
15601560 DDLogVerbose (@" Posting kMonalWillBeFreezed notification now..." );
15611561 [[NSNotificationCenter defaultCenter ] postNotificationName: kMonalWillBeFreezed object: nil ];
@@ -1653,13 +1653,13 @@ -(void) handleBackgroundRefreshingTask:(BGTask*) task
16531653 // this has to be before account disconnects, to detect which accounts are not idle (e.g. have a sync error)
16541654 [HelperTools updateSyncErrorsWithDeleteOnly: YES andWaitForCompletion: YES ];
16551655
1656- // disconnect all accounts to prevent TCP buffer leaking
1657- [[MLXMPPManager sharedInstance ] disconnectAll ];
1658-
16591656 // schedule a new BGProcessingTaskRequest to process this further as soon as possible
16601657 // (if we end up here, the graceful shuttdown did not work out because we are not idle --> we need more cpu time)
16611658 [HelperTools scheduleBackgroundTask: YES ]; // force as soon as possible
16621659
1660+ // disconnect all accounts to prevent TCP buffer leaking
1661+ [[MLXMPPManager sharedInstance ] disconnectAll ];
1662+
16631663 // notify about pending app freeze (don't queue this notification because it should be handled IMMEDIATELY and INLINE)
16641664 DDLogVerbose (@" Posting kMonalWillBeFreezed notification now..." );
16651665 [[NSNotificationCenter defaultCenter ] postNotificationName: kMonalWillBeFreezed object: nil ];
@@ -1880,13 +1880,13 @@ -(void) incomingWakeupWithCompletionHandler:(void (^)(UIBackgroundFetchResult re
18801880 BOOL wasIdle = [[MLXMPPManager sharedInstance ] allAccountsIdle ] && [MLFiletransfer isIdle ];
18811881 [HelperTools updateSyncErrorsWithDeleteOnly: NO andWaitForCompletion: YES ];
18821882
1883- // disconnect all accounts to prevent TCP buffer leaking
1884- [[MLXMPPManager sharedInstance ] disconnectAll ];
1885-
18861883 // schedule a new BGProcessingTaskRequest to process this further as soon as possible, if we are not idle
18871884 // (if we end up here, the graceful shuttdown did not work out because we are not idle --> we need more cpu time)
18881885 [HelperTools scheduleBackgroundTask: !wasIdle];
18891886
1887+ // disconnect all accounts to prevent TCP buffer leaking
1888+ [[MLXMPPManager sharedInstance ] disconnectAll ];
1889+
18901890 // notify about pending app freeze (don't queue this notification because it should be handled IMMEDIATELY and INLINE)
18911891 DDLogVerbose (@" Posting kMonalWillBeFreezed notification now..." );
18921892 [[NSNotificationCenter defaultCenter ] postNotificationName: kMonalWillBeFreezed object: nil ];
0 commit comments