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