Commit 6ad001d4 authored by skummer's avatar skummer

ZP-231 #comment throw a StatusException when WaitForChanges() is terminated...

ZP-231 #comment throw a StatusException when WaitForChanges() is terminated due to another process so we can split between 'no notification' and 'obsolete process' #time 2h

git-svn-id: https://z-push.org/svn/z-push/trunk@1492 b7dd7b3b-3a3c-0410-9da9-bee62a6cc5b5
parent 2839a29f
......@@ -53,6 +53,7 @@
class SyncCollections implements Iterator {
const ERROR_NO_COLLECTIONS = 1;
const ERROR_WRONG_HIERARCHY = 2;
const OBSOLETE_CONNECTION = 3;
private $stateManager;
......@@ -485,9 +486,8 @@ class SyncCollections implements Iterator {
// more than 60 secs to go?
if (($now + 60) < $endat) {
ZLog::Write(LOGLEVEL_DEBUG, sprintf("SyncCollections->CheckForChanges(): Timeout forced after %ss from %ss due to other process", ($now-$started), $lifetime));
ZPush::GetTopCollector()->AnnounceInformation(sprintf("Forced timeout after %ds", ($now-$started)), true);
return false;
throw new StatusException(sprintf("SyncCollections->CheckForChanges(): Timeout forced after %ss from %ss due to other process", ($now-$started), $lifetime), self::OBSOLETE_CONNECTION);
}
}
......
......@@ -163,7 +163,9 @@ class Ping extends RequestProcessor {
$pingstatus = SYNC_PINGSTATUS_FOLDERHIERSYNCREQUIRED;
self::$deviceManager->AnnounceProcessStatus(false, $pingstatus);
break;
case SyncCollections::OBSOLETE_CONNECTION:
$foundchanges = false;
break;
}
}
......
......@@ -592,9 +592,14 @@ class Sync extends RequestProcessor {
}
}
catch (StatusException $stex) {
if ($stex->getCode() == SyncCollections::OBSOLETE_CONNECTION) {
$status = SYNC_COMMONSTATUS_SYNCSTATEVERSIONINVALID;
}
else {
$status = SYNC_STATUS_FOLDERHIERARCHYCHANGED;
self::$topCollector->AnnounceInformation(sprintf("StatusException code: %d", $status), true);
}
}
// in case of an empty sync with no changes, we can reply with an empty response
if ($emptysync && !$foundchanges){
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment