diff options
author | Andrew Dolgov <[email protected]> | 2013-05-29 07:46:14 +0400 |
---|---|---|
committer | Andrew Dolgov <[email protected]> | 2013-05-29 07:46:14 +0400 |
commit | 8ff2a86cf33ed573602a4c6abf8ed8e4ee7c45f9 (patch) | |
tree | 3879bebd7c1a2c73925457623076b4b4acd9f1d9 /include/functions.php | |
parent | f638b40348dfb9c98cacfd6259ea36cce26c0eef (diff) |
fix file_is_locked
Diffstat (limited to 'include/functions.php')
-rw-r--r-- | include/functions.php | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/include/functions.php b/include/functions.php index 01ffa751f..bad01eb96 100644 --- a/include/functions.php +++ b/include/functions.php @@ -961,23 +961,28 @@ } function file_is_locked($filename) { - if (function_exists('flock') && file_exists(LOCK_DIRECTORY . "/$filename")) { - $fp = @fopen(LOCK_DIRECTORY . "/$filename", "r"); - if ($fp) { - if (flock($fp, LOCK_EX | LOCK_NB)) { - flock($fp, LOCK_UN); + if (file_exists(LOCK_DIRECTORY . "/$filename")) { + if (function_exists('flock')) { + $fp = @fopen(LOCK_DIRECTORY . "/$filename", "r"); + if ($fp) { + if (flock($fp, LOCK_EX | LOCK_NB)) { + flock($fp, LOCK_UN); + fclose($fp); + return false; + } 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; } - return true; // consider the file always locked and skip the test } + function make_lockfile($filename) { $fp = fopen(LOCK_DIRECTORY . "/$filename", "w"); |