Some code hardenings for semaphore locking

2022.09-rc
Philipp Holzer 2019-08-26 23:55:54 +02:00
rodzic 720534a82b
commit de7c026590
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: D8365C3D36B77D90
1 zmienionych plików z 2 dodań i 2 usunięć

Wyświetl plik

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