Index: includes/destinations.db.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/backup_migrate/includes/destinations.db.inc,v
retrieving revision 1.1.2.14
retrieving revision 1.1.2.15
diff -u -p -r1.1.2.14 -r1.1.2.15
--- includes/destinations.db.inc	8 May 2010 02:45:38 -0000	1.1.2.14
+++ includes/destinations.db.inc	28 Oct 2010 14:58:58 -0000	1.1.2.15
@@ -1,5 +1,5 @@
 <?php
-// $Id: destinations.db.inc,v 1.1.2.14 2010/05/08 02:45:38 ronan Exp $
+// $Id: destinations.db.inc,v 1.1.2.15 2010/10/28 14:58:58 ronan Exp $
 
 
 /**
@@ -144,15 +144,16 @@ class backup_migrate_destination_db exte
 
     backup_migrate_filters_invoke_all('pre_backup', $this, $file, $settings);
 
-    $this->lock_tables($settings);
-
     // Switch to a different db if specified.
     $this->switch_db();
+
+    $this->lock_tables($settings);
     $success = $this->_backup_db_to_file($file, $settings);
+    $this->unlock_tables($settings);
+
     // Switch back to the previous db.
     $this->switch_db(TRUE);
 
-    $this->unlock_tables($settings);
     backup_migrate_filters_invoke_all('post_backup', $this, $file, $settings, $success);
 
     return $success ? $file : FALSE;
@@ -239,7 +240,6 @@ class backup_migrate_destination_db exte
    */
   function lock_tables($settings) {
     if ($settings->filters['utils_lock_tables']) {
-      $this->switch_db();
       $tables = array();
       foreach ($this->get_table_names() as $table) {
         // There's no need to lock excluded or structure only tables because it doesn't matter if they change.
@@ -248,7 +248,6 @@ class backup_migrate_destination_db exte
         }
       }
       $this->_lock_tables($tables);
-      $this->switch_db(TRUE);
     }
   }
 
