Index: includes/lock.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/lock.inc,v
retrieving revision 1.5
diff -u -p -d -r1.5 lock.inc
--- includes/lock.inc	16 Jul 2010 11:19:38 -0000	1.5
+++ includes/lock.inc	30 Nov 2010 17:11:12 -0000
@@ -103,15 +103,26 @@ function lock_acquire($name, $timeout = 
   $expire = microtime(TRUE) + $timeout;
   if (isset($locks[$name])) {
     // Try to extend the expiration of a lock we already acquired.
+    // Make sure the new expiration is different from the previous one,
+    // so db_update() doesn't return FALSE from affecting zero rows.
+    // We cast to a string to allow the check to work on 32-bit systems.
+    if ((string) $locks[$name] == (string) $expire) {
+      $expire += 0.01;
+    }
     $success = (bool) db_update('semaphore')
       ->fields(array('expire' => $expire))
       ->condition('name', $name)
       ->condition('value', _lock_id())
       ->execute();
-    if (!$success) {
+    if ($success) {
+      // Record the lock's new expiration.
+      $locks[$name] = $expire;
+    }
+    else {
       // The lock was broken.
       unset($locks[$name]);
     }
+
     return $success;
   }
   else {
@@ -128,8 +139,8 @@ function lock_acquire($name, $timeout = 
             'expire' => $expire,
           ))
           ->execute();
-        // We track all acquired locks in the global variable.
-        $locks[$name] = TRUE;
+        // We track all acquired locks and expirations in a global variable.
+        $locks[$name] = $expire;
         // We never need to try again.
         $retry = FALSE;
       }
