From 8d738e667e711c42a74c3eadd21704ad976ca493 Mon Sep 17 00:00:00 2001 From: "steven.lewis" Date: Mon, 29 Apr 2024 11:35:16 +0100 Subject: [PATCH] Fix for reconnecting multi instances in child process when using couchbase version below v4.2.0 --- .../Extensions/Drivers/Couchbasev4/Driver.php | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/lib/Phpfastcache/Extensions/Drivers/Couchbasev4/Driver.php b/lib/Phpfastcache/Extensions/Drivers/Couchbasev4/Driver.php index 657a558..a7096da 100644 --- a/lib/Phpfastcache/Extensions/Drivers/Couchbasev4/Driver.php +++ b/lib/Phpfastcache/Extensions/Drivers/Couchbasev4/Driver.php @@ -179,8 +179,9 @@ protected function handleForkedProcess(): void } if (static::$prepareToForkPPID) { - if (\version_compare(static::$extVersion, '4.2.0', '<')) { + if (\version_compare(static::$extVersion, '4.2.0', '<') && static::$prepareToForkPPID !== $this->currentParentPID) { $this->currentParentPID = static::$prepareToForkPPID; + $this->connect(\posix_getppid()); } if (\version_compare(static::$extVersion, '4.2.1', '>=')) { @@ -189,14 +190,8 @@ protected function handleForkedProcess(): void } else { Cluster::notifyFork(ForkEvent::CHILD); } + static::$prepareToForkPPID = 0; } - - static::$prepareToForkPPID = 0; - } - - if ($this->currentParentPID) { - $this->connect(\posix_getppid()); - $this->currentParentPID = 0; } } }