Index: mollom.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/mollom/mollom.inc,v
retrieving revision 1.1.2.3
diff -u -p -r1.1.2.3 mollom.inc
--- mollom.inc	29 Jan 2010 15:06:32 -0000	1.1.2.3
+++ mollom.inc	9 Sep 2010 01:23:47 -0000
@@ -66,13 +66,21 @@ function _mollom_authentication($public_
  * Refreshes the list of Mollom's XML-RPC servers.
  */
 function _mollom_retrieve_server_list() {
-  // Start from a hard coded list of servers:
+  // Start from a hard-coded list of servers.
   $servers = array('http://xmlrpc1.mollom.com', 'http://xmlrpc2.mollom.com', 'http://xmlrpc3.mollom.com');
+  // Do not use xmlrpc1 in testing mode (until new backend is deployed).
+  if (variable_get('mollom_testing_mode', 0)) {
+    $servers = array_diff($servers, array('http://xmlrpc1.mollom.com', 'http://88.151.243.81'));
+  }
 
   // Use the list of servers to retrieve a list of servers from mollom.com:
   foreach ($servers as $server) {
     $result = xmlrpc($server . '/' . MOLLOM_API_VERSION, 'mollom.getServerList', _mollom_authentication());
     if (!xmlrpc_error()) {
+      // Do not use xmlrpc1 in testing mode (until new backend is deployed).
+      if (is_array($result) && variable_get('mollom_testing_mode', 0)) {
+        $result = array_diff($result, array('http://xmlrpc1.mollom.com', 'http://88.151.243.81'));
+      }
       return $result;
     }
     else {
Index: mollom.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/mollom/mollom.module,v
retrieving revision 1.2.2.157
diff -u -p -r1.2.2.157 mollom.module
--- mollom.module	3 Sep 2010 18:53:51 -0000	1.2.2.157
+++ mollom.module	9 Sep 2010 01:44:51 -0000
@@ -1533,8 +1533,8 @@ function mollom($method, $data = array()
   module_load_include('inc', 'mollom');
   $messages = array();
 
-  // Initialize refresh variable.
-  $refresh = FALSE;
+  // Initialize maximum refreshes.
+  $max_refreshes = 3;
 
   // Enable testing mode.
   if (variable_get('mollom_testing_mode', 0)) {
@@ -1571,11 +1571,10 @@ function mollom($method, $data = array()
       if ($result === FALSE && ($error = xmlrpc_error())) {
         if ($error->code === MOLLOM_REFRESH) {
           // Avoid endless loops.
-          if (!$refresh) {
-            $refresh = TRUE;
-
+          if ($max_refreshes) {
             // Retrieve a new list of valid Mollom servers.
             $servers = _mollom_retrieve_server_list();
+            $max_refreshes--;
             // If API keys are invalid, the XML-RPC error code is returned.
             // To reach this, we must have had a server list (and therefore
             // valid keys) before, so we do not immediately return (like above),
@@ -1600,6 +1599,30 @@ function mollom($method, $data = array()
           // Try the next server in the list.
           $next = next($servers);
 
+          if ($next === FALSE && $max_refreshes) {
+            // Retrieve a new list of valid Mollom servers.
+            $servers = _mollom_retrieve_server_list();
+            $max_refreshes--;
+            // If API keys are invalid, the XML-RPC error code is returned.
+            // To reach this, we must have had a server list (and therefore
+            // valid keys) before, so we do not immediately return (like above),
+            // but instead trigger the fallback mode.
+            if (!is_array($servers)) {
+              break;
+            }
+
+            // Reset the list of servers to restart from the first server.
+            reset($servers);
+
+            // Update the server list.
+            variable_set('mollom_servers', $servers);
+
+            $messages[] = array(
+              'text' => 'Refreshed servers: %servers',
+              'arguments' => array('%servers' => implode(', ', $servers)),
+            );
+          }
+
           $messages[] = array(
             'text' => 'Server %server redirected to: %next.',
             'arguments' => array('%server' => $server, '%next' => $next),
