From afc4552cb097c497b86cbab0e466824ac5e9b3fd Mon Sep 17 00:00:00 2001 From: Ludovic Marcotte Date: Wed, 30 Mar 2016 14:31:57 -0400 Subject: [PATCH] (fix) set minimal interval (fixes #3605) --- ActiveSync/SOGoActiveSyncDispatcher+Sync.m | 7 ++++--- ActiveSync/SOGoActiveSyncDispatcher.m | 7 ++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/ActiveSync/SOGoActiveSyncDispatcher+Sync.m b/ActiveSync/SOGoActiveSyncDispatcher+Sync.m index 4d3e01d42..5ec91c653 100644 --- a/ActiveSync/SOGoActiveSyncDispatcher+Sync.m +++ b/ActiveSync/SOGoActiveSyncDispatcher+Sync.m @@ -1842,7 +1842,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. NSArray *allCollections; NSData *d; - int i, j, defaultInterval, heartbeatInterval, internalInterval, maxSyncResponseSize, total_sleep; + int i, j, defaultInterval, heartbeatInterval, internalInterval, maxSyncResponseSize, total_sleep, sleepInterval; BOOL changeDetected; // We initialize our output buffer @@ -1879,6 +1879,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. maxSyncResponseSize = [[SOGoSystemDefaults sharedSystemDefaults] maximumSyncResponseSize]; heartbeatInterval = [[[(id)[theDocumentElement getElementsByTagName: @"HeartbeatInterval"] lastObject] textValue] intValue]; internalInterval = [defaults internalSyncInterval]; + sleepInterval = (internalInterval < 5) ? internalInterval : 5; // If the request doesn't contain "HeartbeatInterval" there is no reason to delay the response. if (heartbeatInterval == 0) @@ -1965,8 +1966,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. else { [self logWithFormat: @"Sleeping %d seconds while detecting changes in Sync...", internalInterval-total_sleep]; - sleep(5); - total_sleep += 5; + sleep(sleepInterval); + total_sleep += sleepInterval; } } } diff --git a/ActiveSync/SOGoActiveSyncDispatcher.m b/ActiveSync/SOGoActiveSyncDispatcher.m index 2ed5d3b53..47c0453f5 100644 --- a/ActiveSync/SOGoActiveSyncDispatcher.m +++ b/ActiveSync/SOGoActiveSyncDispatcher.m @@ -2041,7 +2041,7 @@ void handle_terminate(int signum) NSData *d; NSAutoreleasePool *pool; - int i, j, heartbeatInterval, defaultInterval, internalInterval, status, total_sleep; + int i, j, heartbeatInterval, defaultInterval, internalInterval, status, total_sleep, sleepInterval; // Let other ping requests know that a new request has arrived. processIdentifier = [NSString stringWithFormat: @"%d", [[NSProcessInfo processInfo] processIdentifier]]; @@ -2055,6 +2055,7 @@ void handle_terminate(int signum) defaults = [SOGoSystemDefaults sharedSystemDefaults]; defaultInterval = [defaults maximumPingInterval]; internalInterval = [defaults internalSyncInterval]; + sleepInterval = (internalInterval < 5) ? internalInterval : 5; if (theDocumentElement) heartbeatInterval = [[[(id)[theDocumentElement getElementsByTagName: @"HeartbeatInterval"] lastObject] textValue] intValue]; @@ -2168,8 +2169,8 @@ void handle_terminate(int signum) else { [self logWithFormat: @"Sleeping %d seconds while detecting changes in Ping...", internalInterval-total_sleep]; - sleep(5); - total_sleep += 5; + sleep(sleepInterval); + total_sleep += sleepInterval; } } }