From 77da6f5583070b465b80e0ffca991ebb2aae171f Mon Sep 17 00:00:00 2001 From: Urban Müller Date: Thu, 11 May 2023 15:27:25 +0200 Subject: store mtime before lock gets touched --- it_url.class | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/it_url.class b/it_url.class index cfa2bef..8594006 100644 --- a/it_url.class +++ b/it_url.class @@ -761,13 +761,15 @@ static function _expired($path, $maxage, $randomexpire = 0) */ static function _lock($path, $p = []) { + $mtime = @filemtime("$path.lock"); + if (!($fh = it::fopen("$path.lock", "w"))) return false; if (!flock($fh, LOCK_EX | LOCK_NB)) { - if (($mtime = @filemtime("$path.lock")) && (time() - $mtime > 30)) - it::error((array)$p['it_error'] + ['title' => "stale lock epired for $path"]); # FIXME 2023-07 DF remove stale lock expiration if never triggered + if ($mtime && (time() - $mtime > 30)) + it::error((array)$p['it_error'] + ['title' => "stale lock epired for $path"]); # FIXME 2024-07 DF remove stale lock expiration if never triggered else return false; } -- cgit v1.2.3