Skip to content

Commit

Permalink
[HttpKernel] Fix race condition when clearing old containers
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolas-grekas committed Nov 29, 2017
1 parent 1f14f4d commit 9d553f5
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/Symfony/Component/HttpKernel/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -644,19 +644,18 @@ protected function initializeContainer()
return;
}

if ($oldContainer) {
if ($oldContainer && get_class($this->container) !== $oldContainer->name) {
// Because concurrent requests might still be using them,
// old container files are not removed immediately,
// but on a next dump of the container.
$oldContainerDir = dirname($oldContainer->getFileName());
foreach (glob(dirname($oldContainerDir).'/*.legacyContainer') as $legacyContainer) {
if (@unlink($legacyContainer)) {
if ($oldContainerDir.'.legacyContainer' !== $legacyContainer && @unlink($legacyContainer)) {
(new Filesystem())->remove(substr($legacyContainer, 0, -16));
}
}
if (get_class($this->container) !== $oldContainer->name) {
touch($oldContainerDir.'.legacyContainer');
}

touch($oldContainerDir.'.legacyContainer');
}

if ($this->container->has('cache_warmer')) {
Expand Down

0 comments on commit 9d553f5

Please sign in to comment.