summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Flatz2024-07-01 09:57:02 +0200
committerDavid Flatz2024-07-01 09:57:02 +0200
commit5c567c34ccdbdcd667541bc0030c71ffb0152806 (patch)
treee0d3e59d08a77c24fd6ae5ce47a567c12469127b
parentb50b0b3ae13fc22c878c29ae49299ca41a7ebbed (diff)
downloaditools-5c567c34ccdbdcd667541bc0030c71ffb0152806.tar.gz
itools-5c567c34ccdbdcd667541bc0030c71ffb0152806.tar.bz2
itools-5c567c34ccdbdcd667541bc0030c71ffb0152806.zip
Remove special case for stale locks since those never occured
-rw-r--r--it_url.class17
1 files changed, 5 insertions, 12 deletions
diff --git a/it_url.class b/it_url.class
index ec20335..a778aed 100644
--- a/it_url.class
+++ b/it_url.class
@@ -612,7 +612,7 @@ static function get_cache($p = array())
{
$fileexists = $filemtime !== true;
- if ($lock = !$p['lock'] ?: it_url::_lock($path, $p))
+ if ($lock = !$p['lock'] ?: it_url::_lock($path))
{
# Touch existing file to prevent locking other getters while refreshing
if ($fileexists)
@@ -665,7 +665,7 @@ static function get_cache($p = array())
if ($filemtime = $isnewfile ? true : it_url::_expired($path, $p['maxage'])) # Outdated(non-zero int) or non-existant(true)?
{
- if ($lock = !$p['lock'] ?: it_url::_lock($path, $p))
+ if ($lock = !$p['lock'] ?: it_url::_lock($path))
{
# Touch existing file to prevent locking other getters while refreshing
if ($filemtime !== true)
@@ -767,20 +767,13 @@ static function _expired($path, $maxage, $randomexpire = 0)
* @param $path File to lock
* @return Lock handle if successfully locked file
*/
-static function _lock($path, $p = [])
+static function _lock($path)
{
- $mtime = @filemtime("$path.lock");
-
if (!($fh = it::fopen("$path.lock", "w")))
return false;
if (!flock($fh, LOCK_EX | LOCK_NB))
- {
- 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;
- }
+ return false;
return $fh;
}
@@ -810,7 +803,7 @@ static function _waitforlockedfile($path, $p)
$sleeptime = 0.1; # seconds to wait per pass
# wait until cache is ready, then read from cache
- for ($maxpasses = $p['timeout'] / $sleeptime, $passes = 0; !($lock = self::_lock("$path", $p)) && ($passes < $maxpasses); ++$passes)
+ for ($maxpasses = $p['timeout'] / $sleeptime, $passes = 0; !($lock = self::_lock("$path")) && ($passes < $maxpasses); ++$passes)
usleep($sleeptime * 1000000);
if (!$lock)