Index: t3lib/class.t3lib_lock.php =================================================================== --- t3lib/class.t3lib_lock.php (revision 8748) +++ t3lib/class.t3lib_lock.php (working copy) @@ -151,22 +151,22 @@ case 'simple': if (is_file($this->resource)) { $this->sysLog('Waiting for a different process to release the lock'); - $i = 0; - while ($i<$this->loops) { - $i++; - usleep($this->step * 1000); - clearstatcache(); - if (!is_file($this->resource)) { // Lock became free, leave the loop - $this->sysLog('Different process released the lock'); - $noWait = FALSE; - break; - } + } + + $isAcquired = FALSE; + for ($i = 0; $i < $this->loops; $i++) { + $filepointer = @fopen($this->resource, 'x'); + if ($filepointer !== FALSE) { + fclose($filepointer); + $this->sysLog('Lock aquired'); + $noWait = ($i === 0); + $isAcquired = TRUE; + break; } - } else { - $noWait = TRUE; + usleep($this->step * 1000); } - if (($this->filepointer = touch($this->resource)) == FALSE) { + if (!$isAcquired) { throw new Exception('Lock file could not be created'); } break;