X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FUtil%2FLock.php;h=9c449844597c56620bb90106ce67bd19fe4772c8;hb=0373056448aec398ee765065adc998aa0da02ac0;hp=93c6d3510099ab18aea9ac56620a90a115983f99;hpb=c0d2e73d0ad0b00562d72364d3453a0e3ec55ed6;p=friendica.git diff --git a/src/Util/Lock.php b/src/Util/Lock.php index 93c6d35100..9c44984459 100644 --- a/src/Util/Lock.php +++ b/src/Util/Lock.php @@ -1,22 +1,24 @@ =')) { self::$semaphore[$fn_name] = sem_get(self::semaphoreKey($fn_name)); if (self::$semaphore[$fn_name]) { return sem_acquire(self::$semaphore[$fn_name], ($timeout == 0)); @@ -120,7 +126,7 @@ class Lock { dba::lock('locks'); $lock = dba::select('locks', array('locked', 'pid'), array('name' => $fn_name), array('limit' => 1)); - if (dbm::is_result($lock)) { + if (DBM::is_result($lock)) { if ($lock['locked']) { // When the process id isn't used anymore, we can safely claim the lock for us. if (!posix_kill($lock['pid'], 0)) { @@ -135,7 +141,7 @@ class Lock { dba::update('locks', array('locked' => true, 'pid' => getmypid()), array('name' => $fn_name)); $got_lock = true; } - } elseif (!dbm::is_result($lock)) { + } elseif (!DBM::is_result($lock)) { dba::insert('locks', array('name' => $fn_name, 'locked' => true, 'pid' => getmypid())); $got_lock = true; } @@ -154,9 +160,11 @@ class Lock { * @brief Removes a lock if it was set by us * * @param string $fn_name Name of the lock + * @return mixed */ - public static function remove($fn_name) { - if (function_exists('sem_get')) { + public static function remove($fn_name) + { + if (function_exists('sem_get') && version_compare(PHP_VERSION, '5.6.1', '>=')) { if (empty(self::$semaphore[$fn_name])) { return false; } else { @@ -185,8 +193,10 @@ class Lock { /** * @brief Removes all lock that were set by us + * @return void */ - public static function removeAll() { + public static function removeAll() + { $memcache = self::connectMemcache(); if (is_object($memcache)) { // We cannot delete all cache entries, but this doesn't matter with memcache