Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F117570507
D5184.1774860728.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Authored By
Unknown
Size
3 KB
Referenced Files
None
Subscribers
None
D5184.1774860728.diff
View Options
diff --git a/lib/ext/Syncroton/Command/Ping.php b/lib/ext/Syncroton/Command/Ping.php
--- a/lib/ext/Syncroton/Command/Ping.php
+++ b/lib/ext/Syncroton/Command/Ping.php
@@ -37,6 +37,22 @@
protected $_changesDetected = false;
protected $_foldersWithChanges = [];
+ private function goToSleep($lifeTime) {
+ // take a break to save battery lifetime
+ call_user_func(Syncroton_Registry::getSleepCallback());
+ sleep(min(Syncroton_Registry::getPingTimeout(), $lifeTime));
+
+ // make sure the connection is still alive, abort otherwise
+ if (connection_aborted()) {
+ if ($this->_logger instanceof Zend_Log) {
+ $this->_logger->debug(__METHOD__ . '::' . __LINE__ . " Exiting on aborted connection");
+ }
+ exit;
+ }
+
+ // reconnect external connections, etc.
+ call_user_func(Syncroton_Registry::getWakeupCallback());
+ }
/**
* process the XML file and add, change, delete or fetches data
*
@@ -123,29 +139,7 @@
}
if ($status === self::STATUS_NO_CHANGES_FOUND) {
- $sleepCallback = Syncroton_Registry::getSleepCallback();
- $wakeupCallback = Syncroton_Registry::getWakeupCallback();
-
do {
- // take a break to save battery lifetime
- call_user_func($sleepCallback);
- sleep(min(Syncroton_Registry::getPingTimeout(), $lifeTime));
-
- // make sure the connection is still alive, abort otherwise
- if (connection_aborted()) {
- if ($this->_logger instanceof Zend_Log) {
- $this->_logger->debug(__METHOD__ . '::' . __LINE__ . " Exiting on aborted connection");
- }
- exit;
- }
-
- // reconnect external connections, etc.
- call_user_func($wakeupCallback);
-
- // Calculate secondsLeft before any loop break just to have a correct value
- // for logging purposes in case we breaked from the loop early
- $secondsLeft = $intervalEnd - time();
-
try {
/** @var Syncroton_Model_Device $device */
$device = $this->_deviceBackend->get($this->_device->id);
@@ -259,13 +253,20 @@
break;
}
- // Update secondsLeft (again)
+ // Update secondsLeft
$secondsLeft = $intervalEnd - time();
if ($this->_logger instanceof Zend_Log) {
$this->_logger->debug(__METHOD__ . '::' . __LINE__ . " DeviceId: " . $this->_device->deviceid . " seconds left: " . $secondsLeft);
}
+ $this->goToSleep($lifeTime);
+
+ // Calculate secondsLeft before any loop break just to have a correct value
+ // for logging purposes in case we breaked from the loop early
+ $secondsLeft = $intervalEnd - time();
+
+
// See: http://www.tine20.org/forum/viewtopic.php?f=12&t=12146
//
// break if there are less than PingTimeout + 10 seconds left for the next loop
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Mar 30, 8:52 AM (4 d, 9 h ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
18800949
Default Alt Text
D5184.1774860728.diff (3 KB)
Attached To
Mode
D5184: Sleep after the loop so we can respond immediately
Attached
Detach File
Event Timeline