diff options
author | Urban Müller | 2023-05-11 15:27:25 +0200 |
---|---|---|
committer | Urban Müller | 2023-05-11 15:27:25 +0200 |
commit | 77da6f5583070b465b80e0ffca991ebb2aae171f (patch) | |
tree | 16bb2c06a64bb57c116e594dfbfc36ded4a299c2 | |
parent | 07437f705b52888cea0fa282401b6df15ab860ce (diff) | |
download | itools-77da6f5583070b465b80e0ffca991ebb2aae171f.tar.gz itools-77da6f5583070b465b80e0ffca991ebb2aae171f.tar.bz2 itools-77da6f5583070b465b80e0ffca991ebb2aae171f.zip |
store mtime before lock gets touched
-rw-r--r-- | it_url.class | 6 |
1 files 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; } |