lib/ext
Aleksander Machniak
machniak at kolabsys.com
Thu Jan 29 12:44:59 CET 2015
lib/ext/Syncroton/Command/Ping.php | 10 +++++++---
lib/ext/Syncroton/Command/Sync.php | 19 ++++++++++++++++---
lib/ext/Syncroton/Server.php | 1 +
3 files changed, 24 insertions(+), 6 deletions(-)
New commits:
commit 9ad07b2dd17d080fa6c737cd0897f33e4bb7b1f1
Author: Aleksander Machniak <alec at alec.pl>
Date: Thu Jan 29 12:35:09 2015 +0100
Fix/Add HeartbeatInterval value checking with Limit response (#4417)
diff --git a/lib/ext/Syncroton/Command/Ping.php b/lib/ext/Syncroton/Command/Ping.php
index a2bd926..2e71fd2 100644
--- a/lib/ext/Syncroton/Command/Ping.php
+++ b/lib/ext/Syncroton/Command/Ping.php
@@ -87,12 +87,16 @@ class Syncroton_Command_Ping extends Syncroton_Command_Wbxml
}
$lifeTime = $this->_device->pinglifetime;
- $maxLifeTime = Syncroton_Registry::getPingInterval();
+ $maxInterval = Syncroton_Registry::getPingInterval();
- if ($maxLifeTime > 0 && $lifeTime > $maxLifeTime) {
+ if ($maxInterval <= 0 || $maxInterval > Syncroton_Server::MAX_HEARTBEAT_INTERVAL) {
+ $maxInterval = Syncroton_Server::MAX_HEARTBEAT_INTERVAL;
+ }
+
+ if ($lifeTime > $maxInterval) {
$ping = $this->_outputDom->documentElement;
$ping->appendChild($this->_outputDom->createElementNS('uri:Ping', 'Status', self::STATUS_INTERVAL_TO_GREAT_OR_SMALL));
- $ping->appendChild($this->_outputDom->createElementNS('uri:Ping', 'HeartbeatInterval', $maxLifeTime));
+ $ping->appendChild($this->_outputDom->createElementNS('uri:Ping', 'HeartbeatInterval', $maxInterval));
return;
}
diff --git a/lib/ext/Syncroton/Command/Sync.php b/lib/ext/Syncroton/Command/Sync.php
index 3a3bc26..e528999 100644
--- a/lib/ext/Syncroton/Command/Sync.php
+++ b/lib/ext/Syncroton/Command/Sync.php
@@ -123,11 +123,24 @@ class Syncroton_Command_Sync extends Syncroton_Command_Wbxml
return $this->_outputDom;
}
-
if (isset($requestXML->HeartbeatInterval)) {
+ $intervalDiv = 1;
$this->_heartbeatInterval = (int)$requestXML->HeartbeatInterval;
- } elseif (isset($requestXML->Wait)) {
- $this->_heartbeatInterval = (int)$requestXML->Wait * 60;
+ } else if (isset($requestXML->Wait)) {
+ $intervalDiv = 60;
+ $this->_heartbeatInterval = (int)$requestXML->Wait * $intervalDiv;
+ }
+
+ $maxInterval = Syncroton_Registry::getPingInterval();
+ if ($maxInterval <= 0 || $maxInterval > Syncroton_Server::MAX_HEARTBEAT_INTERVAL) {
+ $maxInterval = Syncroton_Server::MAX_HEARTBEAT_INTERVAL;
+ }
+
+ if ($this->_heartbeatInterval && $this->_heartbeatInterval > $maxInterval) {
+ $sync = $this->_outputDom->documentElement;
+ $sync->appendChild($this->_outputDom->createElementNS('uri:Sync', 'Status', self::STATUS_WAIT_INTERVAL_OUT_OF_RANGE));
+ $sync->appendChild($this->_outputDom->createElementNS('uri:Sync', 'Limit', floor($maxInterval/$intervalDiv)));
+ $this->_heartbeatInterval = null;
}
$this->_globalWindowSize = isset($requestXML->WindowSize) ? (int)$requestXML->WindowSize : 100;
diff --git a/lib/ext/Syncroton/Server.php b/lib/ext/Syncroton/Server.php
index e89b0fe..0fa4855 100644
--- a/lib/ext/Syncroton/Server.php
+++ b/lib/ext/Syncroton/Server.php
@@ -19,6 +19,7 @@ class Syncroton_Server
const PARAMETER_COLLECTIONID = 1;
const PARAMETER_ITEMID = 3;
const PARAMETER_OPTIONS = 7;
+ const MAX_HEARTBEAT_INTERVAL = 3540; // 59 minutes
protected $_body;
More information about the commits
mailing list