Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 9348519

Browse filesBrowse files
[Cache] fail gracefully when locking is not supported
1 parent 3ab7d57 commit 9348519
Copy full SHA for 9348519

File tree

1 file changed

+4
-2
lines changed
Filter options

1 file changed

+4
-2
lines changed

‎src/Symfony/Component/Cache/LockRegistry.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Cache/LockRegistry.php
+4-2Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,10 @@ public static function compute(callable $callback, ItemInterface $item, bool &$s
9090
while (true) {
9191
try {
9292
// race to get the lock in non-blocking mode
93-
if (flock($lock, LOCK_EX | LOCK_NB)) {
94-
$logger && $logger->info('Lock acquired, now computing item "{key}"', ['key' => $item->getKey()]);
93+
$locked = flock($lock, LOCK_EX | LOCK_NB, $wouldBlock);
94+
95+
if ($locked || !$wouldBlock) {
96+
$logger && $logger->info(sprintf('Lock %s, now computing item "{key}"', $locked ? 'acquired' : 'not supported'), ['key' => $item->getKey()]);
9597
self::$lockedFiles[$key] = true;
9698

9799
$value = $callback($item, $save);

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.