Commit 725bec89 authored by Sebastian Kummer's avatar Sebastian Kummer

Merge pull request #70 in ZP/z-push from bugfix/ZP-728-change-usage-of-sync_max_items to develop

* commit 'bb60cb47':
  ZP-728 Use constant WINDOW_SIZE_MAX for the max window size.
  ZP-728 Use 512 as default WindowSize for a single folder, but limit the GlobalWindowSize to the SYNC_MAX_ITEMS configured.

(cherry picked from commit f262bf07)
parent 39cee131
......@@ -474,13 +474,7 @@ class DeviceManager {
if (isset($this->windowSize[$folderid]))
$items = $this->windowSize[$folderid];
else
$items = (defined("SYNC_MAX_ITEMS")) ? SYNC_MAX_ITEMS : 100;
if (defined("SYNC_MAX_ITEMS") && SYNC_MAX_ITEMS < $items) {
if ($queuedmessages > SYNC_MAX_ITEMS)
ZLog::Write(LOGLEVEL_DEBUG, sprintf("DeviceManager->GetWindowSize() overwriting max items requested of %d by %d forced in configuration.", $items, SYNC_MAX_ITEMS));
$items = SYNC_MAX_ITEMS;
}
$items = WINDOW_SIZE_MAX; // 512 by default
$this->setLatestFolder($folderid);
......@@ -893,4 +887,4 @@ class DeviceManager {
}
}
?>
\ No newline at end of file
?>
......@@ -330,17 +330,28 @@ class SyncCollections implements Iterator {
}
/**
* Returns the global window size which should be used for all collections
* in a case of a heartbeat and/or partial sync
* Returns the global window size of items to be exported in total over all
* requested collections.
*
* @access public
* @return int/boolean returns 512 (max) if not set or not available
* @return int/boolean returns requested windows size, 512 (max) or the
* value of config SYNC_MAX_ITEMS if it is lower
*/
public function GetGlobalWindowSize() {
if (!isset($this->globalWindowSize))
return 512;
// take the requested global windowsize or the max 512 if not defined
if (isset($this->globalWindowSize)) {
$globalWindowSize = $this->globalWindowSize;
}
else {
$globalWindowSize = WINDOW_SIZE_MAX; // 512 by default
}
if (defined("SYNC_MAX_ITEMS") && SYNC_MAX_ITEMS < $globalWindowSize) {
ZLog::Write(LOGLEVEL_DEBUG, sprintf("SyncCollections->GetGlobalWindowSize() overwriting requested global window size of %d by %d forced in configuration.", $globalWindowSize, SYNC_MAX_ITEMS));
$globalWindowSize = SYNC_MAX_ITEMS;
}
return $this->globalWindowSize;
return $globalWindowSize;
}
/**
......@@ -723,4 +734,4 @@ class SyncCollections implements Iterator {
}
}
?>
\ No newline at end of file
?>
......@@ -998,6 +998,7 @@ define("HTTP_CODE_401", 401);
define("HTTP_CODE_449", 449);
define("HTTP_CODE_500", 500);
define("WINDOW_SIZE_MAX", 512);
//logging defs
define("LOGLEVEL_OFF", 0);
......@@ -1064,4 +1065,4 @@ define("AS_REPLYTOSENDER", 1);
define("AS_REPLYTOALL", 2);
define("AS_FORWARD", 3);
?>
\ No newline at end of file
?>
......@@ -232,8 +232,8 @@ class Sync extends RequestProcessor {
if(self::$decoder->getElementStartTag(SYNC_WINDOWSIZE)) {
$ws = self::$decoder->getElementContent();
// normalize windowsize - see ZP-477
if ($ws == 0 || $ws > 512)
$ws = 512;
if ($ws == 0 || $ws > WINDOW_SIZE_MAX)
$ws = WINDOW_SIZE_MAX;
$spa->SetWindowSize($ws);
......@@ -1278,4 +1278,4 @@ class Sync extends RequestProcessor {
}
}
?>
\ No newline at end of file
?>
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