summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2023-02-25 19:30:41 +0300
committerAndrew Dolgov <[email protected]>2023-02-25 19:30:41 +0300
commit4d825fa6a698645dc588bde6ef5339e534b5f31c (patch)
treef453d27166ff5be51669541a101a9825057f2fe4 /include
parenta2af3a6bb4060af2903112101c9b6f4b2801b878 (diff)
require PHP to have support for flock()
Diffstat (limited to 'include')
-rw-r--r--include/functions.php19
1 files changed, 8 insertions, 11 deletions
diff --git a/include/functions.php b/include/functions.php
index 0d7f8c756..5096e9c65 100644
--- a/include/functions.php
+++ b/include/functions.php
@@ -366,21 +366,18 @@
function file_is_locked(string $filename): bool {
if (file_exists(Config::get(Config::LOCK_DIRECTORY) . "/$filename")) {
- if (function_exists('flock')) {
- $fp = @fopen(Config::get(Config::LOCK_DIRECTORY) . "/$filename", "r");
- if ($fp) {
- if (flock($fp, LOCK_EX | LOCK_NB)) {
- flock($fp, LOCK_UN);
- fclose($fp);
- return false;
- }
+ $fp = @fopen(Config::get(Config::LOCK_DIRECTORY) . "/$filename", "r");
+ if ($fp) {
+ if (flock($fp, LOCK_EX | LOCK_NB)) {
+ flock($fp, LOCK_UN);
fclose($fp);
- return true;
- } else {
return false;
}
+ fclose($fp);
+ return true;
+ } else {
+ return false;
}
- return true; // consider the file always locked and skip the test
} else {
return false;
}