Commit d5d96750 authored by Sebastian Kummer's avatar Sebastian Kummer

Merge pull request #78 in ZP/z-push from bugfix/ZP-740-ping-is-not-able-to-wait to develop

* commit '01f2c4a9':
  ZP-740 Set UUID, count & queued when loop data is created by SetSyncStateUsage(), log if IsSyncStateObsolete() does not find any data, log Loopdetection->Detect(), reset loopcount in case of 1.2.1, set type in Detect() if data is created by SetSyncStateUsage().
parents 52e8c88a 01f2c4a9
...@@ -515,6 +515,15 @@ class LoopDetection extends InterProcessData { ...@@ -515,6 +515,15 @@ class LoopDetection extends InterProcessData {
$this->checkArrayStructure($loopdata, $folderid); $this->checkArrayStructure($loopdata, $folderid);
$current = $loopdata[self::$devid][self::$user][$folderid]; $current = $loopdata[self::$devid][self::$user][$folderid];
if (!isset($current["uuid"])) {
$current["uuid"] = $uuid;
}
if (!isset($current["count"])) {
$current["count"] = $counter;
}
if (!isset($current["queued"])) {
$current["queued"] = 0;
}
// update the usage flag // update the usage flag
$current["usage"] = $counter; $current["usage"] = $counter;
...@@ -563,15 +572,23 @@ class LoopDetection extends InterProcessData { ...@@ -563,15 +572,23 @@ class LoopDetection extends InterProcessData {
$obsolete = true; $obsolete = true;
} }
else { else {
ZLog::Write(LOGLEVEL_DEBUG, sprintf("LoopDetection->IsSyncStateObsolete(): check uuid counter: %d - last known counter: %d with %d queued objects", $counter, $current["count"], $current["queued"])); ZLog::Write(LOGLEVEL_DEBUG, sprintf("LoopDetection->IsSyncStateObsolete(): check folderid: '%s' uuid '%s' counter: %d - last counter: %d with %d queued",
$folderid, $uuid, $counter, $current["count"], $current["queued"]));
if ($current["uuid"] == $uuid && ($current["count"] > $counter || ($current["count"] == $counter && $current["queued"] > 0) || (isset($current["usage"]) && $current["usage"] >= $counter))) {
if ($current["uuid"] == $uuid && (
$current["count"] > $counter ||
($current["count"] == $counter && $current["queued"] > 0) ||
(isset($current["usage"]) && $current["usage"] >= $counter)
)) {
$usage = isset($current["usage"]) ? sprintf(" - counter %d already expired",$current["usage"]) : ""; $usage = isset($current["usage"]) ? sprintf(" - counter %d already expired",$current["usage"]) : "";
ZLog::Write(LOGLEVEL_DEBUG, "LoopDetection->IsSyncStateObsolete(): yes, counter already processed". $usage); ZLog::Write(LOGLEVEL_DEBUG, "LoopDetection->IsSyncStateObsolete(): yes, counter already processed". $usage);
$obsolete = true; $obsolete = true;
} }
} }
} }
else {
ZLog::Write(LOGLEVEL_DEBUG, sprintf("LoopDetection->IsSyncStateObsolete(): check folderid: '%s' uuid '%s' counter: %d - no data found: not obsolete", $folderid, $uuid, $counter));
}
} }
return $obsolete; return $obsolete;
...@@ -609,6 +626,7 @@ class LoopDetection extends InterProcessData { ...@@ -609,6 +626,7 @@ class LoopDetection extends InterProcessData {
* @return boolean when returning true if a loop has been identified * @return boolean when returning true if a loop has been identified
*/ */
public function Detect($folderid, $type, $uuid, $counter, $maxItems, $queuedMessages) { public function Detect($folderid, $type, $uuid, $counter, $maxItems, $queuedMessages) {
ZLog::Write(LOGLEVEL_DEBUG, sprintf("LoopDetection->Detect(): folderid:'%s' type:'%s' uuid:'%s' counter:'%s' max:'%s' queued:'%s'", $folderid, $type, $uuid, $counter, $maxItems, $queuedMessages));
$this->broken_message_uuid = $uuid; $this->broken_message_uuid = $uuid;
$this->broken_message_counter = $counter; $this->broken_message_counter = $counter;
...@@ -636,8 +654,14 @@ class LoopDetection extends InterProcessData { ...@@ -636,8 +654,14 @@ class LoopDetection extends InterProcessData {
if (empty($current)) if (empty($current))
$current = array("type" => $type, "uuid" => $uuid, "count" => $counter-1, "queued" => $queuedMessages); $current = array("type" => $type, "uuid" => $uuid, "count" => $counter-1, "queued" => $queuedMessages);
// if data was created by SetSyncStateUsage(), we need to set the type
// TODO ZP-741: type is not used anywhere and could be removed from the loop data
if (isset($current['uuid']) && $current['uuid'] == $uuid && !isset($current['type'])) {
$current['type'] = $type;
}
// old UUID in cache - the device requested a new state!! // old UUID in cache - the device requested a new state!!
else if (isset($current['type']) && $current['type'] == $type && isset($current['uuid']) && $current['uuid'] != $uuid ) { if (isset($current['type']) && $current['type'] == $type && isset($current['uuid']) && $current['uuid'] != $uuid ) {
ZLog::Write(LOGLEVEL_DEBUG, "LoopDetection->Detect(): UUID changed for folder"); ZLog::Write(LOGLEVEL_DEBUG, "LoopDetection->Detect(): UUID changed for folder");
// some devices (iPhones) may request new UUIDs after broken items were sent several times // some devices (iPhones) may request new UUIDs after broken items were sent several times
...@@ -682,6 +706,7 @@ class LoopDetection extends InterProcessData { ...@@ -682,6 +706,7 @@ class LoopDetection extends InterProcessData {
// case 1.2.1 // case 1.2.1
// broken item not identified yet // broken item not identified yet
if (!isset($current['ignored']) && $counter < $current['maxCount']) { if (!isset($current['ignored']) && $counter < $current['maxCount']) {
$current['loopcount'] = 1;
$loop = true; // continue in loop-resolving $loop = true; // continue in loop-resolving
ZLog::Write(LOGLEVEL_DEBUG, "LoopDetection->Detect(): case 1.2.1 detected"); ZLog::Write(LOGLEVEL_DEBUG, "LoopDetection->Detect(): case 1.2.1 detected");
} }
......
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