Fix busy-loop in withQueueLock() on non-EEXIST mkdir failure

If mkdir(queue.lock) failed for a reason other than "already exists"
(e.g. a permissions or disk problem on the data directory), is_dir()
was false, so the loop `continue`d before ever reaching the tries>=40
retry-limit check or the usleep(), spinning at full CPU forever
instead of failing with a clear error.

Move the staleness check inside an is_dir() guard instead of using
continue to skip past the retry-limit logic, so the bounded-retry
behavior applies regardless of why mkdir failed.
This commit is contained in:
Marek Miklewicz
2026-07-04 21:59:13 +02:00
parent bbc1afb5e1
commit a570635d23
2 changed files with 119 additions and 6 deletions
+5 -6
View File
@@ -1295,13 +1295,12 @@ final class BackupQueueService
$tries = 0;
while (!@mkdir($lockDir, 0700)) {
$tries++;
if (!is_dir($lockDir)) {
continue;
}
$mtime = (int)@filemtime($lockDir);
if ($mtime > 0 && (time() - $mtime) > 120) {
@rmdir($lockDir);
if (is_dir($lockDir)) {
$mtime = (int)@filemtime($lockDir);
if ($mtime > 0 && (time() - $mtime) > 120) {
@rmdir($lockDir);
}
}
if ($tries >= 40) {