http://www.mediawiki.org/wiki/Special:Code/MediaWiki/66275
Revision: 66275 Author: platonides Date: 2010-05-12 15:03:07 +0000 (Wed, 12 May 2010) Log Message: ----------- Store the Tor list update status in a new memcache key, to avoid missing the items during the update. This way, loadExitNodes can be run every 25-28 minutes and MediaWiki will always have a list to work with. Probably solves bug 23321 Modified Paths: -------------- trunk/extensions/TorBlock/TorBlock.class.php Modified: trunk/extensions/TorBlock/TorBlock.class.php =================================================================== --- trunk/extensions/TorBlock/TorBlock.class.php 2010-05-12 14:23:27 UTC (rev 66274) +++ trunk/extensions/TorBlock/TorBlock.class.php 2010-05-12 15:03:07 UTC (rev 66275) @@ -102,9 +102,21 @@ wfDebug( "Loading Tor exit node list from memcached.\n" ); // Lucky. return self::$mExitNodes = $nodes; - } elseif ($nodes == 'loading') { - // Somebody else is loading it. - return array(); + } else { + $liststatus = $wgMemc->get( 'mw-tor-list-status' ); + if ( $liststatus == 'loading' ) { + // Somebody else is loading it. + wfDebug( "Old Tor list expired and we are still loading the new one.\n" ); + return array(); + } else if ( $liststatus == 'loaded' ) { + $nodes = $wgMemc->get( 'mw-tor-exit-nodes' ); + if (is_array($nodes)) { + return self::$mExitNodes = $nodes; + } else { + wfDebug( "Tried very hard to get the Tor list since mw-tor-list-status says it is loaded, to no avail.\n" ); + return array(); + } + } } // We have to actually load from the server. @@ -128,7 +140,7 @@ // Set loading key, to prevent DoS of server. - $wgMemc->set( 'mw-tor-exit-nodes', 'loading', 300 ); + $wgMemc->set( 'mw-tor-list-status', 'loading', 300 ); $nodes = array(); foreach( $wgTorIPs as $ip ) { @@ -137,6 +149,7 @@ // Save to cache. $wgMemc->set( 'mw-tor-exit-nodes', $nodes, 1800 ); // Store for half an hour. + $wgMemc->set( 'mw-tor-list-status', 'loaded', 1800 ); wfProfileOut( __METHOD__ ); _______________________________________________ MediaWiki-CVS mailing list MediaWiki-CVS@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs