From 1452d19892fc53d9b29990c3eed13a3f03de799a Mon Sep 17 00:00:00 2001 From: Ferdinand Kuhl Date: Mon, 16 May 2022 12:04:25 +0200 Subject: [PATCH] Safe one unneccessary check against redis lock --- Classes/Http/SessionLockRequestComponent.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Classes/Http/SessionLockRequestComponent.php b/Classes/Http/SessionLockRequestComponent.php index 97a6da4..1a0b546 100644 --- a/Classes/Http/SessionLockRequestComponent.php +++ b/Classes/Http/SessionLockRequestComponent.php @@ -73,14 +73,14 @@ class SessionLockRequestComponent implements ComponentInterface $this->logger->debug('SessionLock: Try to get "' . $key . '"'); $timedOut = \time() + $this->secondsToWait; - while (!$lock->acquire() || $timedOut <= \time()) { + while (!$lock->acquire()) { \usleep(100000); - } - if (!$lock->isAcquired()) { - throw new LockAcquiringException( - 'Could not acquire the lock for "' . $key . '" in ' . $this->secondsToWait . ' seconds.', - 1652687960 - ); + if (\time() >= $timedOut) { + throw new LockAcquiringException( + 'Could not acquire the lock for "' . $key . '" in ' . $this->secondsToWait . ' seconds.', + 1652687960 + ); + } } $this->logger->debug('SessionLock: Acquired "' . $key . '"'); }