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 0222ea5

Browse filesBrowse files
committed
bug #33703 [Cache] fail gracefully when locking is not supported (nicolas-grekas)
This PR was merged into the 4.3 branch. Discussion ---------- [Cache] fail gracefully when locking is not supported | Q | A | ------------- | --- | Branch? | 4.3 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | Fix #33392 | License | MIT | Doc PR | - Commits ------- 9348519 [Cache] fail gracefully when locking is not supported
2 parents d52515a + 9348519 commit 0222ea5
Copy full SHA for 0222ea5

File tree

Expand file treeCollapse file tree

1 file changed

+4
-2
lines changed
Filter options
Expand file treeCollapse file tree

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.