Skip to content

Commit

Permalink
Fix concurrent writing and reading on workers boot (#1137)
Browse files Browse the repository at this point in the history
Co-authored-by: Aleksei Gagarin <[email protected]>
  • Loading branch information
wapmorgan and roxblnfk authored Sep 8, 2024
1 parent 3ec14f8 commit bbff436
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/Boot/src/Memory.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,14 @@ public function loadData(string $section, string &$filename = null): mixed
}

try {
return include($filename);
$fp = \fopen($filename, 'r');
if (!\flock($fp, \LOCK_SH | \LOCK_NB)) {
return null;
}
$data = include($filename);
\flock($fp, \LOCK_UN);
\fclose($fp);
return $data;
} catch (\Throwable) {
return null;
}
Expand Down

0 comments on commit bbff436

Please sign in to comment.