]> git.wh0rd.org - tt-rss.git/commitdiff
fix file_is_locked
authorAndrew Dolgov <fox@madoka.volgo-balt.ru>
Wed, 29 May 2013 03:46:14 +0000 (07:46 +0400)
committerAndrew Dolgov <fox@madoka.volgo-balt.ru>
Wed, 29 May 2013 03:46:14 +0000 (07:46 +0400)
include/functions.php

index 01ffa751fd7393e4925e2e09acc0c9c539772263..bad01eb96777643dc387bb5ac68b1cb365676c15 100644 (file)
        }
 
        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");