r76874 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r76873‎ | r76874 | r76875 >
Date:04:01, 17 November 2010
Author:tstarling
Status:deferred
Tags:
Comment:
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 (modified) (history)
  • /trunk/wap/hawpedia.php (modified) (history)
  • /trunk/wap/image.php (modified) (history)

Diff [purge]

Index: trunk/wap/hawpedia.php
@@ -202,6 +202,7 @@
203203 curl_setopt($ch, CURLOPT_URL, $url);
204204 curl_setopt($ch, CURLOPT_HEADER, 0);
205205 curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
 206+ curl_setopt($ch, CURLOPT_TIMEOUT, HAWPEDIA_TIMEOUT);
206207
207208 // WP otherwise says: "Please provide a User-Agent header"
208209 curl_setopt($ch, CURLOPT_USERAGENT, "hawpedia");
@@ -245,6 +246,7 @@
246247 curl_setopt($ch, CURLOPT_NOBODY, TRUE);
247248 curl_setopt($ch, CURLOPT_FAILONERROR, TRUE);
248249 curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
 250+ curl_setopt($ch, CURLOPT_TIMEOUT, HAWPEDIA_TIMEOUT );
249251 curl_exec($ch);
250252 $status = curl_getinfo( $ch, CURLINFO_HTTP_CODE );
251253 curl_close($ch);
@@ -273,6 +275,7 @@
274276 curl_setopt($ch, CURLOPT_URL, $url);
275277 curl_setopt($ch, CURLOPT_HEADER, 0);
276278 curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
 279+ curl_setopt($ch, CURLOPT_TIMEOUT, HAWPEDIA_TIMEOUT);
277280 $curlResultString = curl_exec($ch);
278281 if (!is_string($curlResultString))
279282 hawpedia_error(hawtra("Wikipedia currently not available")); // exits internally
Index: trunk/wap/image.php
@@ -3,6 +3,8 @@
44 # echo($_SERVER['QUERY_STRING']);
55 # echo($_SERVER['HTTP_ACCEPT']);
66
 7+require( dirname( __FILE__ ) . "/config.php" );
 8+
79 function fatalError($msg) {
810 header("HTTP/1.0 500 Internal Server Error");
911 echo "$msg\n";
@@ -41,6 +43,7 @@
4244 curl_setopt($ch, CURLOPT_URL, $url);
4345 curl_setopt($ch, CURLOPT_HEADER, 0);
4446 curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
 47+ curl_setopt($ch, CURLOPT_TIMEOUT, HAWPEDIA_TIMEOUT);
4548
4649 // WP otherwise says: "Please provide a User-Agent header"
4750 curl_setopt($ch, CURLOPT_USERAGENT, "hawpedia");
Index: trunk/wap/config.php
@@ -23,6 +23,9 @@
2424 define("SEGLENGTH_HTML", 2000);
2525 define("SEGLENGTH_VXML", 10000000);
2626
 27+// Timeout for HTTP fetches, in seconds
 28+define("HAWPEDIA_TIMEOUT", 5 );
 29+
2730 // comment out next line to disable vxml dispatcher
2831 //define("HAWPEDIA_VXML_TMP_FILE", "/tmp/hawpedia_vxml_dispatcher.tmp");
2932

Status & tagging log