use socket timeout of 10 sec to stay responsive even with a slow internet connection or a not working server

This commit is contained in:
Frank Karlitschek 2012-10-08 11:53:00 +02:00
parent 4dba91838f
commit b7a5cc2fda
1 changed files with 10 additions and 1 deletions

View File

@ -42,7 +42,16 @@ class OC_Updater{
//fetch xml data from updater
$url=$updaterurl.'?version='.$versionstring;
$xml=@file_get_contents($url);
// set a sensible timeout of 10 sec to stay responsive even if the update server is down.
$ctx = stream_context_create(
array(
'http' => array(
'timeout' => 10
)
)
);
$xml=@file_get_contents($url, 0, $ctx);
if($xml==FALSE) {
return array();
}