Commit 73303706 authored by skummer's avatar skummer

ZP-249 #comment changed flag of SetSyncStateUsage() - the new counter is set....

ZP-249 #comment changed flag of SetSyncStateUsage() - the new counter is set. IsSyncStateObsolete looks how the flag is related to the checked counter #time 1h 30m

git-svn-id: https://z-push.org/svn/z-push/trunk@1563 b7dd7b3b-3a3c-0410-9da9-bee62a6cc5b5
parent 093ad44f
......@@ -629,13 +629,12 @@ class DeviceManager {
* @param string $folderid folder id
* @param string $uuid synkkey
* @param string $counter synckey counter
* @param int $flags
*
* @access public
* @return
*/
public function SetHeartbeatStateIntegrity($folderid, $uuid, $counter, $flags = 1) {
return $this->loopdetection->SetSyncStateUsage($folderid, $uuid, $counter, $flags);
public function SetHeartbeatStateIntegrity($folderid, $uuid, $counter) {
return $this->loopdetection->SetSyncStateUsage($folderid, $uuid, $counter);
}
/**
......
......@@ -484,25 +484,25 @@ class LoopDetection extends InterProcessData {
* @param string $folderid folder id
* @param string $uuid synkkey
* @param string $counter synckey counter
* @param int $flags
*
* @access public
* @return boolean
*/
public function SetSyncStateUsage($folderid, $uuid, $counter, $flags) {
public function SetSyncStateUsage($folderid, $uuid, $counter) {
// initialize params
$this->InitializeParams();
ZLog::Write(LOGLEVEL_DEBUG, sprintf("LoopDetection->SetSyncStateUsage(): uuid: %s counter: %d", $uuid, $counter));
// exclusive block
if ($this->blockMutex()) {
$loopdata = ($this->hasData()) ? $this->getData() : array();
// check and initialize the array structure
$this->checkArrayStructure($loopdata, $folderid);
$current = $loopdata[self::$devid][self::$user][$folderid];
// update the usage flag
$current["usage"] = $flags;
$current["usage"] = $counter;
// update loop data
$loopdata[self::$devid][self::$user][$folderid] = $current;
......@@ -549,18 +549,12 @@ class LoopDetection extends InterProcessData {
}
ZLog::Write(LOGLEVEL_DEBUG, sprintf("LoopDetection->IsSyncStateObsolete(): check uuid counter: %d - last known counter: %d with %d queued objects", $counter, $current["count"], $current["queued"]));
if ($current["uuid"] == $uuid && ($current["count"] > $counter || ($current["count"] == $counter && $current["queued"] > 0))) {
ZLog::Write(LOGLEVEL_DEBUG, "LoopDetection->IsSyncStateObsolete(): yes, counter already processed");
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"]) : "";
ZLog::Write(LOGLEVEL_DEBUG, "LoopDetection->IsSyncStateObsolete(): yes, counter already processed". $usage);
$obsolete = true;
}
if (isset($current["usage"]) && $current["uuid"] == $uuid && $current["count"] == $counter) {
ZLog::Write(LOGLEVEL_DEBUG, sprintf("LoopDetection->IsSyncStateObsolete(): yes, state is already in use, flag: %d", $current["usage"]));
$obsolete = true;
}
}
}
return $obsolete;
......@@ -661,6 +655,8 @@ class LoopDetection extends InterProcessData {
// case 1.1
$current['count'] = $counter;
$current['queued'] = $queuedMessages;
if (isset($current["usage"]) && $current["usage"] < $current['count'])
unset($current["usage"]);
// case 1.2
if (isset($current['maxCount'])) {
......@@ -686,6 +682,8 @@ class LoopDetection extends InterProcessData {
// case 2 - same counter, but there were no changes before and are there now
else if ($current['count'] == $counter && $current['queued'] == 0 && $queuedMessages > 0) {
$current['queued'] = $queuedMessages;
if (isset($current["usage"]) && $current["usage"] < $current['count'])
unset($current["usage"]);
}
// case 3 - same counter, changes sent before, hanging loop and ignoring
......
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