Skip to content

Commit

Permalink
bug #27669 [Filesystem] fix file lock on SunOS (fritzmg)
Browse files Browse the repository at this point in the history
This PR was merged into the 2.8 branch.

Discussion
----------

[Filesystem] fix file lock on SunOS

| Q             | A
| ------------- | ---
| Branch?       | 2.8
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | -
| License       | MIT
| Doc PR        | -

See #27668

Commits
-------

7adb641 fix file lock on SunOS
  • Loading branch information
nicolas-grekas committed Jun 21, 2018
2 parents 749410a + 7adb641 commit f63579d
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/Symfony/Component/Filesystem/LockHandler.php
Expand Up @@ -75,12 +75,12 @@ public function lock($blocking = false)
$error = $msg;
});

if (!$this->handle = fopen($this->file, 'r')) {
if (!$this->handle = fopen($this->file, 'r+') ?: fopen($this->file, 'r')) {
if ($this->handle = fopen($this->file, 'x')) {
chmod($this->file, 0444);
} elseif (!$this->handle = fopen($this->file, 'r')) {
} elseif (!$this->handle = fopen($this->file, 'r+') ?: fopen($this->file, 'r')) {
usleep(100); // Give some time for chmod() to complete
$this->handle = fopen($this->file, 'r');
$this->handle = fopen($this->file, 'r+') ?: fopen($this->file, 'r');
}
}
restore_error_handler();
Expand Down

0 comments on commit f63579d

Please sign in to comment.