@@ -1412,8 +1412,8 @@ -(void) checkIfBackgroundTaskIsStillNeeded
1412
1412
[DDLog flushLog ];
1413
1413
DDLogVerbose (@" Setting _shutdownPending to YES..." );
1414
1414
_shutdownPending = YES ;
1415
- [[MLXMPPManager sharedInstance ] disconnectAll ]; // disconnect all accounts to prevent TCP buffer leaking
1416
1415
[HelperTools scheduleBackgroundTask: NO ]; // request bg fetch execution in BGFETCH_DEFAULT_INTERVAL seconds
1416
+ [[MLXMPPManager sharedInstance ] disconnectAll ]; // disconnect all accounts to prevent TCP buffer leaking
1417
1417
[HelperTools dispatchAsync: NO reentrantOnQueue: dispatch_get_main_queue () withBlock: ^{
1418
1418
BOOL stopped = NO ;
1419
1419
// 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
1490
1490
// this has to be before account disconnects, to detect which accounts are not idle (e.g. have a sync error)
1491
1491
[HelperTools updateSyncErrorsWithDeleteOnly: NO andWaitForCompletion: YES ];
1492
1492
1493
- // disconnect all accounts to prevent TCP buffer leaking
1494
- [[MLXMPPManager sharedInstance ] disconnectAll ];
1495
-
1496
1493
// schedule a BGProcessingTaskRequest to process this further as soon as possible
1497
1494
// (if we end up here, the graceful shuttdown did not work out because we are not idle --> we need more cpu time)
1498
1495
[HelperTools scheduleBackgroundTask: YES ]; // force as soon as possible
1499
1496
1497
+ // disconnect all accounts to prevent TCP buffer leaking
1498
+ [[MLXMPPManager sharedInstance ] disconnectAll ];
1499
+
1500
1500
// notify about pending app freeze (don't queue this notification because it should be handled IMMEDIATELY and INLINE)
1501
1501
DDLogVerbose (@" Posting kMonalWillBeFreezed notification now..." );
1502
1502
[[NSNotificationCenter defaultCenter ] postNotificationName: kMonalWillBeFreezed object: nil ];
@@ -1549,13 +1549,13 @@ -(void) handleBackgroundProcessingTask:(BGTask*) task
1549
1549
// this has to be before account disconnects, to detect which accounts are not idle (e.g. have a sync error)
1550
1550
[HelperTools updateSyncErrorsWithDeleteOnly: YES andWaitForCompletion: YES ];
1551
1551
1552
- // disconnect all accounts to prevent TCP buffer leaking
1553
- [[MLXMPPManager sharedInstance ] disconnectAll ];
1554
-
1555
1552
// schedule a new BGProcessingTaskRequest to process this further as soon as possible
1556
1553
// (if we end up here, the graceful shuttdown did not work out because we are not idle --> we need more cpu time)
1557
1554
[HelperTools scheduleBackgroundTask: YES ]; // force as soon as possible
1558
1555
1556
+ // disconnect all accounts to prevent TCP buffer leaking
1557
+ [[MLXMPPManager sharedInstance ] disconnectAll ];
1558
+
1559
1559
// notify about pending app freeze (don't queue this notification because it should be handled IMMEDIATELY and INLINE)
1560
1560
DDLogVerbose (@" Posting kMonalWillBeFreezed notification now..." );
1561
1561
[[NSNotificationCenter defaultCenter ] postNotificationName: kMonalWillBeFreezed object: nil ];
@@ -1653,13 +1653,13 @@ -(void) handleBackgroundRefreshingTask:(BGTask*) task
1653
1653
// this has to be before account disconnects, to detect which accounts are not idle (e.g. have a sync error)
1654
1654
[HelperTools updateSyncErrorsWithDeleteOnly: YES andWaitForCompletion: YES ];
1655
1655
1656
- // disconnect all accounts to prevent TCP buffer leaking
1657
- [[MLXMPPManager sharedInstance ] disconnectAll ];
1658
-
1659
1656
// schedule a new BGProcessingTaskRequest to process this further as soon as possible
1660
1657
// (if we end up here, the graceful shuttdown did not work out because we are not idle --> we need more cpu time)
1661
1658
[HelperTools scheduleBackgroundTask: YES ]; // force as soon as possible
1662
1659
1660
+ // disconnect all accounts to prevent TCP buffer leaking
1661
+ [[MLXMPPManager sharedInstance ] disconnectAll ];
1662
+
1663
1663
// notify about pending app freeze (don't queue this notification because it should be handled IMMEDIATELY and INLINE)
1664
1664
DDLogVerbose (@" Posting kMonalWillBeFreezed notification now..." );
1665
1665
[[NSNotificationCenter defaultCenter ] postNotificationName: kMonalWillBeFreezed object: nil ];
@@ -1880,13 +1880,13 @@ -(void) incomingWakeupWithCompletionHandler:(void (^)(UIBackgroundFetchResult re
1880
1880
BOOL wasIdle = [[MLXMPPManager sharedInstance ] allAccountsIdle ] && [MLFiletransfer isIdle ];
1881
1881
[HelperTools updateSyncErrorsWithDeleteOnly: NO andWaitForCompletion: YES ];
1882
1882
1883
- // disconnect all accounts to prevent TCP buffer leaking
1884
- [[MLXMPPManager sharedInstance ] disconnectAll ];
1885
-
1886
1883
// schedule a new BGProcessingTaskRequest to process this further as soon as possible, if we are not idle
1887
1884
// (if we end up here, the graceful shuttdown did not work out because we are not idle --> we need more cpu time)
1888
1885
[HelperTools scheduleBackgroundTask: !wasIdle];
1889
1886
1887
+ // disconnect all accounts to prevent TCP buffer leaking
1888
+ [[MLXMPPManager sharedInstance ] disconnectAll ];
1889
+
1890
1890
// notify about pending app freeze (don't queue this notification because it should be handled IMMEDIATELY and INLINE)
1891
1891
DDLogVerbose (@" Posting kMonalWillBeFreezed notification now..." );
1892
1892
[[NSNotificationCenter defaultCenter ] postNotificationName: kMonalWillBeFreezed object: nil ];
0 commit comments