diff --git a/ActiveSync/SOGoActiveSyncDispatcher+Sync.m b/ActiveSync/SOGoActiveSyncDispatcher+Sync.m index 23c13fe1e..0f16be544 100644 --- a/ActiveSync/SOGoActiveSyncDispatcher+Sync.m +++ b/ActiveSync/SOGoActiveSyncDispatcher+Sync.m @@ -2599,9 +2599,36 @@ FIXME // We enter our loop detection change for (i = 0; i < (heartbeatInterval/internalInterval); i++) { + // Terminate the process if we need to if ([self easShouldTerminate]) break; + // We first check of any of the collections we want to sync are already + // in an other sync process. If that's the case, we do not do anything + // and we return immediately. So we'll let the other sync process terminate + for (j = 0; j < [allCollections count]; j++) + { + aCollection = [allCollections objectAtIndex: j]; + globalMetadata = [self globalMetadataForDevice]; + + key = [NSString stringWithFormat: @"SyncRequest+%@", [[[(id)[aCollection getElementsByTagName: @"CollectionId"] lastObject] textValue] stringByUnescapingURL]]; + + if (!([[globalMetadata objectForKey: key] isEqual: processIdentifier])) + { + if (debugOn) + [self logWithFormat: @"EAS - Discard response %@", [self globalMetadataForDevice]]; + + [output appendString: @"13"]; + [output appendString: @""]; + d = [[output dataUsingEncoding: NSUTF8StringEncoding] xml2wbxml]; + [theResponse setContent: d]; + RELEASE(output); + return; + } + + } + + // We're good to go to sync the collections s = [NSMutableString string]; for (j = 0; j < [allCollections count]; j++) @@ -2613,21 +2640,6 @@ FIXME changeDetected: &changeDetected maxSyncResponseSize: maxSyncResponseSize]; - // Don't return a response if another Sync is waiting. - globalMetadata = [self globalMetadataForDevice]; - key = [NSString stringWithFormat: @"SyncRequest+%@", [[[(id)[aCollection getElementsByTagName: @"CollectionId"] lastObject] textValue] stringByUnescapingURL]]; - - if (!([[globalMetadata objectForKey: key] isEqual: processIdentifier])) - { - if (debugOn) - [self logWithFormat: @"EAS - Discard response %@", [self globalMetadataForDevice]]; - - [theResponse setStatus: 503]; - - RELEASE(output); - return; - } - if ((maxSyncResponseSize > 0 && [s length] >= maxSyncResponseSize)) break; } diff --git a/NEWS b/NEWS index 3dbfc6995..5f4daaa88 100644 --- a/NEWS +++ b/NEWS @@ -5,6 +5,7 @@ Bug fixes - [core] properly update the last-modified attribute (#4313) - [web] prevent deletion of special folders using del key - [eas] improved alarms syncing with EAS devices (#4351) + - [eas] avoid potential cache update when breaking sync queries (#4422) 4.0.0 (2018-03-07) ------------------