Reduce connect timeout in MediaWiki::triggerJobs
authorErik Bernhardson <ebernhardson@wikimedia.org>
Tue, 25 Mar 2014 22:31:56 +0000 (15:31 -0700)
committerErik Bernhardson <ebernhardson@wikimedia.org>
Tue, 25 Mar 2014 22:31:56 +0000 (15:31 -0700)
The fifth parameter to fsockopen is the number of seconds
to wait before declaring the connection a failure. When not
provided it defaults to the php ini value of 'default_socket_timeout'
which is 60s.  Under no circumstances should we wait 60s to
connect to ourselves,  100ms seems like a reasonable timeout
since its explicitly connecting to itself, but the exact timeout
could be slightly longer.

Change-Id: I18d328274ddf1e0848fce40ebf39e0466b5c4d5d

includes/Wiki.php

index 4bf8fd3..6cf718c 100644 (file)
@@ -655,7 +655,10 @@ class MediaWiki {
                        $info['host'],
                        isset( $info['port'] ) ? $info['port'] : 80,
                        $errno,
-                       $errstr
+                       $errstr,
+                       // If it takes more than 100ms to connect to ourselves there
+                       // is a problem elsewhere.
+                       0.1
                );
                wfRestoreWarnings();
                if ( !$sock ) {