From 8c73d9273fd981a87bd27a20a883bc9a2d49f012 Mon Sep 17 00:00:00 2001 From: Thomas Steur Date: Tue, 15 Dec 2020 16:49:39 +1300 Subject: Avoid filesystem checks when process was set as finished (#16954) Because in CliMulti we might check in a loop for every process constantly if they are finished. It won't help all that much but better to not check every time the file system when it is not needed. There be many other things we could improve there. Will add some comments but probably best not to do them (or we'll see if it's needed later) --- core/CliMulti/Process.php | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'core') diff --git a/core/CliMulti/Process.php b/core/CliMulti/Process.php index daed5a85c4..bb0583c4ad 100644 --- a/core/CliMulti/Process.php +++ b/core/CliMulti/Process.php @@ -21,6 +21,7 @@ use Piwik\SettingsServer; */ class Process { + private $finished = null; private $pidFile = ''; private $timeCreation = null; private $isSupported = null; @@ -81,6 +82,10 @@ class Process public function hasFinished() { + if ($this->finished) { + return true; + } + $content = $this->getPidFileContent(); return !$this->doesPidFileExist($content); @@ -129,6 +134,7 @@ class Process public function finishProcess() { + $this->finished = true; Filesystem::deleteFileIfExists($this->pidFile); } -- cgit v1.2.3