From 8ff2a86cf33ed573602a4c6abf8ed8e4ee7c45f9 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Wed, 29 May 2013 07:46:14 +0400 Subject: fix file_is_locked --- include/functions.php | 25 +++++++++++++++---------- 1 file 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"); -- cgit v1.2.3