(fix) prevent double Sync ops from same device (fixes #3603)
This commit is contained in:
parent
feca4ca3a5
commit
821b9d1f3c
|
@ -2015,11 +2015,12 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
- (void) processPing: (id <DOMElement>) theDocumentElement
|
- (void) processPing: (id <DOMElement>) theDocumentElement
|
||||||
inResponse: (WOResponse *) theResponse
|
inResponse: (WOResponse *) theResponse
|
||||||
{
|
{
|
||||||
NSString *collectionId, *realCollectionId, *syncKey;
|
NSString *collectionId, *realCollectionId, *syncKey, *processIdentifier, *pingRequestInCache;
|
||||||
NSMutableArray *foldersWithChanges, *allFoldersID;
|
NSMutableArray *foldersWithChanges, *allFoldersID;
|
||||||
SOGoMicrosoftActiveSyncFolderType folderType;
|
SOGoMicrosoftActiveSyncFolderType folderType;
|
||||||
NSMutableDictionary *folderMetadata;
|
NSMutableDictionary *folderMetadata;
|
||||||
SOGoSystemDefaults *defaults;
|
SOGoSystemDefaults *defaults;
|
||||||
|
SOGoCacheGCSObject *o;
|
||||||
id <DOMElement> aCollection;
|
id <DOMElement> aCollection;
|
||||||
NSArray *allCollections;
|
NSArray *allCollections;
|
||||||
|
|
||||||
|
@ -2028,8 +2029,17 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
NSData *d;
|
NSData *d;
|
||||||
NSAutoreleasePool *pool;
|
NSAutoreleasePool *pool;
|
||||||
|
|
||||||
int i, j, heartbeatInterval, defaultInterval, internalInterval, status;
|
int i, j, heartbeatInterval, defaultInterval, internalInterval, status, total_sleep;
|
||||||
|
|
||||||
|
// Let other ping requests know that a new request has arrived.
|
||||||
|
processIdentifier = [NSString stringWithFormat: @"%d", [[NSProcessInfo processInfo] processIdentifier]];
|
||||||
|
o = [SOGoCacheGCSObject objectWithName: [context objectForKey: @"DeviceId"] inContainer: nil useCache: NO];
|
||||||
|
[o setObjectType: ActiveSyncGlobalCacheObject];
|
||||||
|
[o setTableUrl: [self folderTableURL]];
|
||||||
|
[o reloadIfNeeded];
|
||||||
|
[[o properties] setObject: processIdentifier forKey: @"PingRequest"];
|
||||||
|
[o save];
|
||||||
|
|
||||||
defaults = [SOGoSystemDefaults sharedSystemDefaults];
|
defaults = [SOGoSystemDefaults sharedSystemDefaults];
|
||||||
defaultInterval = [defaults maximumPingInterval];
|
defaultInterval = [defaults maximumPingInterval];
|
||||||
internalInterval = [defaults internalSyncInterval];
|
internalInterval = [defaults internalSyncInterval];
|
||||||
|
@ -2123,8 +2133,30 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
[self logWithFormat: @"Sleeping %d seconds while detecting changes in Ping...", internalInterval];
|
total_sleep = 0;
|
||||||
sleep(internalInterval);
|
|
||||||
|
while (total_sleep < internalInterval)
|
||||||
|
{
|
||||||
|
// We check if we must break the current ping request since an other ping request
|
||||||
|
// has just arrived.
|
||||||
|
pingRequestInCache = [[self globalMetadataForDevice] objectForKey: @"PingRequest"];
|
||||||
|
if (pingRequestInCache && ![pingRequestInCache isEqualToString: processIdentifier])
|
||||||
|
{
|
||||||
|
if (debugOn)
|
||||||
|
[self logWithFormat: @"EAS - Ping request canceled (%@)", pingRequestInCache];
|
||||||
|
|
||||||
|
// Make sure we end the heardbeat-loop.
|
||||||
|
internalInterval = heartbeatInterval;
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
[self logWithFormat: @"Sleeping %d seconds while detecting changes in Ping...", internalInterval-total_sleep];
|
||||||
|
sleep(5);
|
||||||
|
total_sleep += 5;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue