diff --git a/servers.php b/servers.php index 5a0d344..d36040e 100644 --- a/servers.php +++ b/servers.php @@ -103,6 +103,14 @@ function cleanup() { if ($tmp = @fopen($tmpfile, 'x')) break; // we have the temp file, so fetch new data + // If the temp file is stale (e.g. the writer crashed without cleanup), + // remove it and try again immediately + if (file_exists($tmpfile) && filemtime($tmpfile) < time() - 30) { + error_log("Stale lock file detected for $cachefile, removing"); + unlink($tmpfile); + continue; + } + if (time() > $start + 20) { // don't wait forever die("Can't obtain temporary file\n"); }