Skip to content

Conversation

@joelwurtz
Copy link
Member

@joelwurtz joelwurtz commented Jul 16, 2024

There can be race condition when multiple php process would generate the class at the same time, so we add a lock here to avoid this problem

Better diff with ?w=1

@joelwurtz joelwurtz force-pushed the feat/lock-load-class branch from 3494fea to e1b0fe4 Compare July 16, 2024 15:13
Copy link
Member

@lyrixx lyrixx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, thanks


if ($this->reloadStrategy === FileReloadStrategy::NEVER && file_exists($classPath)) {
require $classPath;
// We lock the file here, because another process could be writing the file at the same time
Copy link
Member

@Korbeil Korbeil Jul 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we wait until the other process is done (waiting on lock release) until returning this method ?
So we are sure the file is generated.

@Korbeil Korbeil merged commit deb3f27 into main Aug 30, 2024
@Korbeil Korbeil deleted the feat/lock-load-class branch August 30, 2024 13:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants