]> git.mxchange.org Git - friendica.git/commitdiff
Some code hardenings for semaphore locking
authorPhilipp Holzer <admin+github@philipp.info>
Mon, 26 Aug 2019 21:55:54 +0000 (23:55 +0200)
committerPhilipp Holzer <admin+github@philipp.info>
Mon, 26 Aug 2019 21:55:54 +0000 (23:55 +0200)
src/Core/Lock/SemaphoreLock.php

index d5153d432e46b0ccf68a27f6e18e02c1429fcb48..adfab5fc0e7d4a85eebe565f663567bae2093f8b 100644 (file)
@@ -39,8 +39,8 @@ class SemaphoreLock extends Lock
        public function acquireLock($key, $timeout = 120, $ttl = Cache\Cache::FIVE_MINUTES)
        {
                self::$semaphore[$key] = sem_get(self::semaphoreKey($key));
-               if (self::$semaphore[$key]) {
-                       if (sem_acquire(self::$semaphore[$key], ($timeout == 0))) {
+               if (!empty(self::$semaphore[$key])) {
+                       if ((bool)sem_acquire(self::$semaphore[$key], ($timeout === 0))) {
                                $this->markAcquire($key);
                                return true;
                        }