Skip to content

Commit

Permalink
Don't use heartbeat/wait interval as a flag for a hanging sync.
Browse files Browse the repository at this point in the history
We can't assume clients using EAS version 12.1 or above actually use
a hanging sync. Introduce a new flag to indicate a hanging sync since
we can't rely on heartbeat/wait interval (these will also be present
when PINGing).

Fixes regression caused by 2a6a67b.
  • Loading branch information
mrubinsk committed May 19, 2014
1 parent a235e92 commit cb3849c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
13 changes: 11 additions & 2 deletions framework/ActiveSync/lib/Horde/ActiveSync/Collections.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,13 @@ class Horde_ActiveSync_Collections implements IteratorAggregate
*/
protected $_changes;

/**
* Flag to indicate the client is requesting a hanging SYNC.
*
* @var boolean
*/
protected $_hangingSync = false;

/**
* Const'r
*
Expand Down Expand Up @@ -208,6 +215,7 @@ public function __get($property)
return $this->_cache->$property;
case 'importedChanges':
case 'shortSyncRequest':
case 'hangingSync':
$p = '_' . $property;
return $this->$p;
}
Expand All @@ -223,6 +231,7 @@ public function __set($property, $value)
switch ($property) {
case 'importedChanges':
case 'shortSyncRequest':
case 'hangingSync':
$p = '_' . $property;
$this->$p = $value;
return;
Expand Down Expand Up @@ -548,7 +557,7 @@ public function getHeartbeat()
*/
public function canDoLoopingSync()
{
return !$this->_importedChanges && ($this->_shortSyncRequest || $this->_cache->hbinterval !== false || $this->_cache->wait !== false);
return $this->_hangingSync && !$this->_importedChanges && ($this->_shortSyncRequest || $this->_cache->hbinterval !== false || $this->_cache->wait !== false);
}

/**
Expand Down Expand Up @@ -809,7 +818,7 @@ public function initPartialSync()
public function canSendEmptyResponse()
{
return !$this->_importedChanges &&
($this->_cache->wait !== false || $this->_cache->hbinterval !== false);
($this->_hangingSync && ($this->_cache->wait !== false || $this->_cache->hbinterval !== false));
}

/**
Expand Down
4 changes: 4 additions & 0 deletions framework/ActiveSync/lib/Horde/ActiveSync/Request/Sync.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ protected function _handle()
return true;
}
$this->_collections->shortSyncRequest = true;
$this->_collections->hangingSync = true;
$this->_collections->save();
}
} else {
Expand All @@ -150,6 +151,7 @@ protected function _handle()
}
} else {
// Start decoding request.
$this->_collections->hangingSync = false;
while (($sync_tag = ($this->_decoder->getElementStartTag(Horde_ActiveSync::SYNC_WINDOWSIZE) ? Horde_ActiveSync::SYNC_WINDOWSIZE :
($this->_decoder->getElementStartTag(Horde_ActiveSync::SYNC_FOLDERS) ? Horde_ActiveSync::SYNC_FOLDERS :
($this->_decoder->getElementStartTag(Horde_ActiveSync::SYNC_PARTIAL) ? Horde_ActiveSync::SYNC_PARTIAL :
Expand All @@ -161,6 +163,7 @@ protected function _handle()
case Horde_ActiveSync::SYNC_HEARTBEATINTERVAL:
if ($hbinterval = $this->_decoder->getElementContent()) {
$this->_collections->setHeartbeat(array('hbinterval' => $hbinterval));
$this->_collections->hangingSync = true;
$this->_decoder->getElementEndTag();
if ($hbinterval > (self::MAX_HEARTBEAT)) {
$this->_logger->err(sprintf(
Expand All @@ -176,6 +179,7 @@ protected function _handle()
case Horde_ActiveSync::SYNC_WAIT:
if ($wait = $this->_decoder->getElementContent()) {
$this->_collections->setHeartbeat(array('wait' => $wait));
$this->_collections->hangingSync = true;
$this->_decoder->getElementEndTag();
if ($wait > (self::MAX_HEARTBEAT / 60)) {
$this->_logger->err(sprintf(
Expand Down

0 comments on commit cb3849c

Please sign in to comment.