Skip to content

Commit 7291118

Browse files
Prophet777andig
authored andcommitted
Fix infinite reload after tracked file changed (php-pm#400)
1 parent ec84915 commit 7291118

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/ProcessManager.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -875,7 +875,15 @@ protected function checkChangedFiles($restartSlaves = true)
875875
continue;
876876
}
877877

878-
if ($knownMTime !== filemtime($filePath) && $this->filesLastMd5[$filePath] !== md5_file($filePath, true)) {
878+
$actualFileTime = filemtime($filePath);
879+
$actualFileHash = md5_file($filePath);
880+
881+
if ($knownMTime !== $actualFileTime && $this->filesLastMd5[$filePath] !== $actualFileHash) {
882+
883+
// update tracked entry metadata
884+
$this->filesLastMd5[$filePath] = $actualFileHash;
885+
$this->filesLastMTime[$filePath] = $actualFileTime;
886+
879887
$this->output->writeln(
880888
sprintf("<info>[%s] File %s has changed.</info>", date('d/M/Y:H:i:s O'), $filePath)
881889
);
@@ -1030,7 +1038,7 @@ public function closeSlaves($graceful = false, $onSlaveClosed = null)
10301038
$onSlaveClosed($slave);
10311039
}
10321040
}
1033-
1041+
10341042
if ($this->reloadTimeoutTimer !== null) {
10351043
$this->reloadTimeoutTimer->cancel();
10361044
}

0 commit comments

Comments
 (0)