From b7a5cc2fda1484e8a054820ef026bbaeccf31c77 Mon Sep 17 00:00:00 2001
From: Frank Karlitschek <frank@owncloud.org>
Date: Mon, 8 Oct 2012 11:53:00 +0200
Subject: [PATCH] use socket timeout of 10 sec to stay responsive even with a
 slow internet connection or a not working server

---
 lib/updater.php | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/lib/updater.php b/lib/updater.php
index ad42f2bf60..b3b289ef27 100644
--- a/lib/updater.php
+++ b/lib/updater.php
@@ -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();
                 }
-- 
GitLab