Commit 22e722d5 authored by skummer's avatar skummer

ZP-551 #comment different processing time for different device classes

git-svn-id: https://z-push.org/svn/z-push/trunk@1926 b7dd7b3b-3a3c-0410-9da9-bee62a6cc5b5
parent 7c2f3a25
......@@ -188,6 +188,7 @@ class FolderSync extends RequestProcessor {
$exporter->InitializeExporter($changesMem);
// Stream all changes to the ImportExportChangesMem
$maxExporttime = Request::GetExpectedConnectionTimeout();
$totalChanges = $exporter->GetChangeCount();
$started = time();
$exported = 0;
......@@ -198,10 +199,11 @@ class FolderSync extends RequestProcessor {
if (time() % 4 ) {
self::$topCollector->AnnounceInformation(sprintf("Exported %d from %d folders", $exported, $totalChanges));
}
// stop if this takes more than 20 seconds
if (USE_PARTIAL_FOLDERSYNC && (time() - $started) > 20) {
// if partial sync is allowed, stop if this takes too long
if (USE_PARTIAL_FOLDERSYNC && (time() - $started) > $maxExporttime) {
ZLog::Write(LOGLEVEL_WARN, sprintf("Request->HandleFolderSync(): Exporting folders is too slow. In %d seconds only %d from %d changes were processed.",(time() - $started), $exported, $totalChanges));
self::$topCollector->AnnounceInformation(sprintf("Partial export of %d folders", $totalChanges), true);
self::$topCollector->AnnounceInformation(sprintf("Partial export of %d out of %d folders", $exported, $totalChanges), true);
self::$deviceManager->SetFolderSyncComplete(false);
$partial = true;
break;
......
......@@ -581,6 +581,32 @@ class Request {
return (isset(self::$headers["content-length"]))? (int) self::$headers["content-length"] : 0;
}
/**
* Returns the amount of seconds this request is able to be kept open without the client
* closing it. This depends on the vendor.
*
* @access public
* @return boolean
*/
static public function GetExpectedConnectionTimeout() {
// Different vendors implement different connection timeouts.
// In order to optimize processing, we return a specific time for the major
// classes currently known (feedback welcome).
// The amount of time returned is somehow lower than the max timeout so we have
// time for processing.
// Apple and Windows Phone have higher timeouts (4min = 240sec)
if (in_array(self::GetDeviceType(), array("iPod", "iPad", "iPhone", "WP"))) {
return 200;
}
// Samsung devices have a intermediate timeout (90sec)
if (in_array(self::GetDeviceType(), array("SAMSUNGGTI"))) {
return 50;
}
// for all other devices, a timeout of 30 seconds is expected
return 20;
}
/**----------------------------------------------------------------------------------------------------------
* Private stuff
......
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