From d83cd29e93d4adeaad1b844007168be3bebe0222 Mon Sep 17 00:00:00 2001 From: Thomas Steur Date: Tue, 15 Dec 2020 16:51:45 +1300 Subject: Remember if process ever started (#16950) * Remember if process ever started This can potentially bring a performance improvement as I think sometimes the system would wait for 8 seconds before declaring a process as finished even if it finished after 1s. What happens is in https://github.com/matomo-org/matomo/blob/4.0.5/core/CliMulti.php#L217-L222 it checks if the process has started by checking if the PID file exists. However, the `RequestCommand` deletes the PID file as soon as the process finished to signal "it finished". That means when we check in that loop whether the process has started, it would think it hasn't started yet and simply continue until 8s have past and then it would set the process as finished. Vs we can simply remember that once we say once "the process has started" flag then we can always remember this. I would assume this race condition would happen constantly unless I'm not seeing it right. * fix test --- tests/PHPUnit/Integration/CliMulti/ProcessTest.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/PHPUnit/Integration/CliMulti/ProcessTest.php b/tests/PHPUnit/Integration/CliMulti/ProcessTest.php index 383733de53..229a687587 100644 --- a/tests/PHPUnit/Integration/CliMulti/ProcessTest.php +++ b/tests/PHPUnit/Integration/CliMulti/ProcessTest.php @@ -121,11 +121,20 @@ class ProcessTest extends \PHPUnit\Framework\TestCase $this->assertTrue($this->process->hasFinished()); } - public function test_hasStarted() + public function test_hasStarted_startedWhenContentFalse() { $this->assertTrue($this->process->hasStarted(false)); + } + + public function test_hasStarted_startedWhenPidGiven() + { $this->assertTrue($this->process->hasStarted('6341')); + // remembers the process was started at some point + $this->assertTrue($this->process->hasStarted('')); + } + public function test_hasStarted_notStartedYetEmptyContentInPid() + { $this->assertFalse($this->process->hasStarted('')); } -- cgit v1.2.3