From 26497271fdd53b972af0b3a4411b6ce41a0629c0 Mon Sep 17 00:00:00 2001
From: Andreas Gohr <andi@splitbrain.org>
Date: Sun, 6 Feb 2011 16:11:51 +0100
Subject: [PATCH] correctly wait for a lock in indexer (related to FS#2112)

---
 lib/exe/indexer.php | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/lib/exe/indexer.php b/lib/exe/indexer.php
index eec8c968c..010ca7987 100644
--- a/lib/exe/indexer.php
+++ b/lib/exe/indexer.php
@@ -149,6 +149,7 @@ function runIndexer(){
     }
 
     // try to aquire a lock
+    $run = 0;
     $lock = $conf['lockdir'].'/_indexer.lock';
     while(!@mkdir($lock,$conf['dmode'])){
         usleep(50);
@@ -156,7 +157,8 @@ function runIndexer(){
             // looks like a stale lock - remove it
             @rmdir($lock);
             print "runIndexer(): stale lock removed".NL;
-        }else{
+        }elseif($run++ = 1000){
+            // we waited 5 seconds for that lock
             print "runIndexer(): indexer locked".NL;
             return false;
         }
-- 
GitLab