Index: trunk/extensions/TorBlock/TorBlock.class.php |
— | — | @@ -102,9 +102,21 @@ |
103 | 103 | wfDebug( "Loading Tor exit node list from memcached.\n" ); |
104 | 104 | // Lucky. |
105 | 105 | return self::$mExitNodes = $nodes; |
106 | | - } elseif ($nodes == 'loading') { |
107 | | - // Somebody else is loading it. |
108 | | - return array(); |
| 106 | + } else { |
| 107 | + $liststatus = $wgMemc->get( 'mw-tor-list-status' ); |
| 108 | + if ( $liststatus == 'loading' ) { |
| 109 | + // Somebody else is loading it. |
| 110 | + wfDebug( "Old Tor list expired and we are still loading the new one.\n" ); |
| 111 | + return array(); |
| 112 | + } else if ( $liststatus == 'loaded' ) { |
| 113 | + $nodes = $wgMemc->get( 'mw-tor-exit-nodes' ); |
| 114 | + if (is_array($nodes)) { |
| 115 | + return self::$mExitNodes = $nodes; |
| 116 | + } else { |
| 117 | + wfDebug( "Tried very hard to get the Tor list since mw-tor-list-status says it is loaded, to no avail.\n" ); |
| 118 | + return array(); |
| 119 | + } |
| 120 | + } |
109 | 121 | } |
110 | 122 | |
111 | 123 | // We have to actually load from the server. |
— | — | @@ -128,7 +140,7 @@ |
129 | 141 | |
130 | 142 | // Set loading key, to prevent DoS of server. |
131 | 143 | |
132 | | - $wgMemc->set( 'mw-tor-exit-nodes', 'loading', 300 ); |
| 144 | + $wgMemc->set( 'mw-tor-list-status', 'loading', 300 ); |
133 | 145 | |
134 | 146 | $nodes = array(); |
135 | 147 | foreach( $wgTorIPs as $ip ) { |
— | — | @@ -137,6 +149,7 @@ |
138 | 150 | |
139 | 151 | // Save to cache. |
140 | 152 | $wgMemc->set( 'mw-tor-exit-nodes', $nodes, 1800 ); // Store for half an hour. |
| 153 | + $wgMemc->set( 'mw-tor-list-status', 'loaded', 1800 ); |
141 | 154 | |
142 | 155 | wfProfileOut( __METHOD__ ); |
143 | 156 | |