[Cache] fail gracefully when locking is not supported

This commit is contained in:
Nicolas Grekas 2019-09-25 15:53:41 +02:00
parent 3ab7d57659
commit 93485190f9

View File

@ -90,8 +90,10 @@ final class LockRegistry
while (true) {
try {
// race to get the lock in non-blocking mode
if (flock($lock, LOCK_EX | LOCK_NB)) {
$logger && $logger->info('Lock acquired, now computing item "{key}"', ['key' => $item->getKey()]);
$locked = flock($lock, LOCK_EX | LOCK_NB, $wouldBlock);
if ($locked || !$wouldBlock) {
$logger && $logger->info(sprintf('Lock %s, now computing item "{key}"', $locked ? 'acquired' : 'not supported'), ['key' => $item->getKey()]);
self::$lockedFiles[$key] = true;
$value = $callback($item, $save);