]> git.mxchange.org Git - friendica.git/commitdiff
More general check for semaphore
authorAlexandre Alapetite <alexandre@alapetite.fr>
Wed, 28 Jun 2017 20:38:22 +0000 (22:38 +0200)
committerAlexandre Alapetite <alexandre@alapetite.fr>
Wed, 28 Jun 2017 20:38:22 +0000 (22:38 +0200)
src/Util/Lock.php

index 3988294b0f4026ea7a9f4c5123bc6925639a2f4a..ca75b0d666daa433e9dfccbb7ba55b24688eee62 100644 (file)
@@ -156,8 +156,14 @@ class Lock {
         * @param string $fn_name Name of the lock
         */
        public static function remove($fn_name) {
-               if (function_exists('sem_get') && self::$semaphore[$fn_name]) {
-                       return @sem_release(self::$semaphore[$fn_name]);
+               if (function_exists('sem_get')) {
+                       if (empty(self::$semaphore[$fn_name])) {
+                               return false;
+                       } else {
+                               $rid = self::$semaphore[$fn_name];
+                               self::$semaphore[$fn_name] = 0;
+                               return @sem_release($rid);
+                       }
                }
 
                $memcache = self::connectMemcache();