http://www.mediawiki.org/wiki/Special:Code/MediaWiki/76874
Revision: 76874 Author: tstarling Date: 2010-11-17 04:01:33 +0000 (Wed, 17 Nov 2010) Log Message: ----------- Added a curl timeout, so that the WAP server doesn't lock up every time LVS loses some connections Modified Paths: -------------- trunk/wap/config.php trunk/wap/hawpedia.php trunk/wap/image.php Modified: trunk/wap/config.php =================================================================== --- trunk/wap/config.php 2010-11-17 03:05:12 UTC (rev 76873) +++ trunk/wap/config.php 2010-11-17 04:01:33 UTC (rev 76874) @@ -23,6 +23,9 @@ define("SEGLENGTH_HTML", 2000); define("SEGLENGTH_VXML", 10000000); +// Timeout for HTTP fetches, in seconds +define("HAWPEDIA_TIMEOUT", 5 ); + // comment out next line to disable vxml dispatcher //define("HAWPEDIA_VXML_TMP_FILE", "/tmp/hawpedia_vxml_dispatcher.tmp"); Modified: trunk/wap/hawpedia.php =================================================================== --- trunk/wap/hawpedia.php 2010-11-17 03:05:12 UTC (rev 76873) +++ trunk/wap/hawpedia.php 2010-11-17 04:01:33 UTC (rev 76874) @@ -202,6 +202,7 @@ curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); + curl_setopt($ch, CURLOPT_TIMEOUT, HAWPEDIA_TIMEOUT); // WP otherwise says: "Please provide a User-Agent header" curl_setopt($ch, CURLOPT_USERAGENT, "hawpedia"); @@ -245,6 +246,7 @@ curl_setopt($ch, CURLOPT_NOBODY, TRUE); curl_setopt($ch, CURLOPT_FAILONERROR, TRUE); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); + curl_setopt($ch, CURLOPT_TIMEOUT, HAWPEDIA_TIMEOUT ); curl_exec($ch); $status = curl_getinfo( $ch, CURLINFO_HTTP_CODE ); curl_close($ch); @@ -273,6 +275,7 @@ curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); + curl_setopt($ch, CURLOPT_TIMEOUT, HAWPEDIA_TIMEOUT); $curlResultString = curl_exec($ch); if (!is_string($curlResultString)) hawpedia_error(hawtra("Wikipedia currently not available")); // exits internally Modified: trunk/wap/image.php =================================================================== --- trunk/wap/image.php 2010-11-17 03:05:12 UTC (rev 76873) +++ trunk/wap/image.php 2010-11-17 04:01:33 UTC (rev 76874) @@ -3,6 +3,8 @@ # echo($_SERVER['QUERY_STRING']); # echo($_SERVER['HTTP_ACCEPT']); +require( dirname( __FILE__ ) . "/config.php" ); + function fatalError($msg) { header("HTTP/1.0 500 Internal Server Error"); echo "$msg\n"; @@ -41,6 +43,7 @@ curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); + curl_setopt($ch, CURLOPT_TIMEOUT, HAWPEDIA_TIMEOUT); // WP otherwise says: "Please provide a User-Agent header" curl_setopt($ch, CURLOPT_USERAGENT, "hawpedia"); _______________________________________________ MediaWiki-CVS mailing list MediaWiki-CVS@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs