From: Andrew Dolgov Date: Wed, 12 Dec 2012 05:46:02 +0000 (+0400) Subject: add built-in expiring of obsolete lockfiles X-Git-Tag: 1.6.2~3 X-Git-Url: https://git.wh0rd.org/?a=commitdiff_plain;h=2a91b6ff78145a3ed955f7617b00e404ad6357b6;p=tt-rss.git add built-in expiring of obsolete lockfiles --- diff --git a/include/rssfuncs.php b/include/rssfuncs.php index b5949d72..1b39efec 100644 --- a/include/rssfuncs.php +++ b/include/rssfuncs.php @@ -141,6 +141,7 @@ } expire_cached_files($debug); + expire_lock_files($debug); // For each feed, we call the feed update function. while ($line = array_pop($feeds_to_update)) { @@ -1394,6 +1395,27 @@ return $doc->saveXML($node, LIBXML_NOEMPTYTAG); } + function expire_lock_files($debug) { + if ($debug) _debug("Removing old lock files..."); + + $num_deleted = 0; + + if (is_writable(LOCK_DIRECTORY)) { + $files = glob(LOCK_DIRECTORY . "/*.lock"); + + if ($files) { + foreach ($files as $file) { + if (!file_is_locked($file) && time() - filemtime($file) > 86400*2) { + unlink($file); + ++$num_deleted; + } + } + } + } + + if ($debug) _debug("Removed $num_deleted files."); + } + function expire_cached_files($debug) { foreach (array("magpie", "simplepie", "images", "export") as $dir) { $cache_dir = CACHE_DIR . "/$dir"; @@ -1405,7 +1427,7 @@ if (is_writable($cache_dir)) { $files = glob("$cache_dir/*"); - if ($files) + if ($files) { foreach ($files as $file) { if (time() - filemtime($file) > 86400*7) { unlink($file); @@ -1414,6 +1436,7 @@ } } } + } if ($debug) _debug("Removed $num_deleted files."); }