]> git.mxchange.org Git - friendica.git/commitdiff
Merge pull request #7570 from nupplaphil/bug/friendica-7298
authorHypolite Petovan <hypolite@mrpetovan.com>
Thu, 29 Aug 2019 19:02:07 +0000 (15:02 -0400)
committerGitHub <noreply@github.com>
Thu, 29 Aug 2019 19:02:07 +0000 (15:02 -0400)
Some code hardenings for semaphore locking

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;
                        }