Skip to content
Snippets Groups Projects
Commit 9f881d09 authored by Michael Hamann's avatar Michael Hamann
Browse files

Only remove the indexer lock when there is really a stale lock

Previously the rmdir could be executed when the lock directory had been
deleted by another indexer already. This could lead to a race condition
when another indexer call creates the lock again between the if and the
rmdir. This issue still exists for stale lock directories but they
normally shouldn't exist.
This also prevents the loop from becoming an endless loop when the lock
directory can't be created.
This change also fixes a syntax error in the indexer and prevents an
endless loop when the lock directory exists but can't be deleted.
parent 0993d1c5
No related branches found
No related tags found
No related merge requests found
......@@ -153,11 +153,15 @@ function runIndexer(){
$lock = $conf['lockdir'].'/_indexer.lock';
while(!@mkdir($lock,$conf['dmode'])){
usleep(50);
if(time()-@filemtime($lock) > 60*5){
if(is_dir($lock) && time()-@filemtime($lock) > 60*5){
// looks like a stale lock - remove it
@rmdir($lock);
print "runIndexer(): stale lock removed".NL;
}elseif($run++ = 1000){
if (!@rmdir($lock)) {
print "runIndexer(): removing the stale lock failed".NL;
return false;
} else {
print "runIndexer(): stale lock removed".NL;
}
}elseif($run++ == 1000){
// we waited 5 seconds for that lock
print "runIndexer(): indexer locked".NL;
return false;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment