8000 bug #52201 [HttpKernel] Resolve EBADP error on flock with LOCK_SH wit… · symfony/symfony@c4558e7 · GitHub
[go: up one dir, main page]

Skip to content

Commit c4558e7

Browse files
committed
bug #52201 [HttpKernel] Resolve EBADP error on flock with LOCK_SH with NFS (driskell)
This PR was merged into the 5.4 branch. Discussion ---------- [HttpKernel] Resolve EBADP error on flock with LOCK_SH with NFS | Q | A | ------------- | --- | Branch? | 5.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | Fix #52144 | License | MIT When using NFSv3 (with rpc.statd with NLM) or NFSv4, or any other filesystem where flock is converted to fcntl, performing flock LOCK_SH due to a would-be-blocking LOCK_EX will trigger EBADP and return false, and bypass the cache lock, due to the lock file not being opened with read mode. This causes cache locking to not have any effect on these filesystems. Changing the lock file open to w+ resolve this issue and makes cache locking effective on NFS and other similar filesystems which convert flock calls to fcntl. As per fcntl documentation: In order to place a read lock, fd must be open for reading. In order to place a write lock, fd must be open for writing. To place both types of lock, open a file read-write. Commits ------- 8be417d [HttpKernel] Resolve EBADP error on flock with LOCK_SH with NFS
2 parents 0aa03ae + 8be417d commit c4558e7

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/Symfony/Component/HttpKernel/Kernel.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,7 @@ protected function initializeContainer()
467467
try {
468468
is_dir($buildDir) ?: mkdir($buildDir, 0777, true);
469469

470-
if ($lock = fopen($cachePath.'.lock', 'w')) {
470+
if ($lock = fopen($cachePath.'.lock', 'w+')) {
471471
if (!flock($lock, \LOCK_EX | \LOCK_NB, $wouldBlock) && !flock($lock, $wouldBlock ? \LOCK_SH : \LOCK_EX)) {
472472
fclose($lock);
473473
$lock = null;

0 commit comments

Comments
 (0)
0