#973436: don't bother waiting for the variable cache to be rebuilt.

From: Damien Tournoud <damien@commerceguys.com>


---
 bootstrap.inc |   17 +++++++----------
 1 files changed, 7 insertions(+), 10 deletions(-)

diff --git includes/bootstrap.inc includes/bootstrap.inc
index 0938c89..3443450 100644
--- includes/bootstrap.inc
+++ includes/bootstrap.inc
@@ -729,17 +729,14 @@ function variable_initialize($conf = array()) {
     $variables = $cached->data;
   }
   else {
-    // Cache miss. Avoid a stampede.
+    // Cache miss. Avoid a stampede by acquiring a lock. If the lock fails to
+    // acquire, just continue with uncached processing.
     $name = 'variable_init';
-    if (!lock_acquire($name, 1)) {
-      // Another request is building the variable cache.
-      // Wait, then re-run this function.
-      lock_wait($name);
-      return variable_initialize($conf);
-    }
-    else {
-      // Proceed with variable rebuild.
-      $variables = array_map('unserialize', db_query('SELECT name, value FROM {variable}')->fetchAllKeyed());
+    $lock_acquired = lock_acquire($name, 1);
+
+    // Load the variables from the table.
+    $variables = array_map('unserialize', db_query('SELECT name, value FROM {variable}')->fetchAllKeyed());
+    if ($lock_acquired) {
       cache_set('variables', $variables, 'cache_bootstrap');
       lock_release($name);
     }
