Merge pull request #7570 from nupplaphil/bug/friendica-7298

Some code hardenings for semaphore locking
This commit is contained in:
Hypolite Petovan 2019-08-29 15:02:07 -04:00 committed by GitHub
commit ce7ec11d1d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

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