Skip to content

Commit 16dca4e

Browse files
authored
Merge pull request #8 from srjlewis/master
Notify parent and child process at the same time
2 parents 65f0c77 + c32b7cf commit 16dca4e

File tree

5 files changed

+18
-3
lines changed

5 files changed

+18
-3
lines changed

.github/workflows/php.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
strategy:
1818
matrix:
1919
operating-system: [ubuntu-latest]
20-
php-versions: ['8.0', '8.1', '8.2', '8.3']
20+
php-versions: ['8.0', '8.1', '8.2', '8.3', '8.4']
2121
ext-versions: ['couchbase-4.1.6', 'couchbase']
2222
name: PHP ${{ matrix.php-versions }} using ${{ matrix.ext-versions }} quality/tests on ${{ matrix.operating-system }}
2323
env:

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
## 9.2.3
2+
#### 27 November 2024
3+
- __Driver Core__
4+
- `Couchbasev4` Allow call to `handleNotifyFork()` after process has been forked, this is due
5+
- to a change in the couchbase SDK that needs parent and child to be notified at the same time.
6+
7+
18
## 9.2.2
29
#### 29 July 2024
310
- __Driver Core__

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,16 @@ composer install phpfastcache/couchbasev4-extension
3333

3434
To fork a php process correctly you will need to tell the Couchbase diver to prepare for the fork.
3535

36-
⚠️ __WARNING__ You **must** call the drivers `Phpfastcache\Drivers\Couchbasev4\Driver::prepareToFork()` just before the `pcntl_fork()` call or the child process will lock up.
36+
⚠️ __WARNING__ You **must** call the drivers `Phpfastcache\Drivers\Couchbasev4\Driver::prepareToFork()`
37+
just before the `pcntl_fork()` call or the child process will lock up and then call `handleNotifyFork()` to avoid further
38+
errors.
3739

3840
#### Example
3941
```php
4042
try {
4143
\Phpfastcache\Drivers\Couchbasev4\Driver::prepareToFork();
4244
$pid = pcntl_fork();
45+
\Phpfastcache\Drivers\Couchbasev4\Driver::handleNotifyFork();
4346
if ($pid == -1) {
4447
// There was a problem with forking the process
4548
} else if ($pid) {

lib/Phpfastcache/Extensions/Drivers/Couchbasev4/Driver.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,8 +199,12 @@ protected function handleForkedProcess(): void
199199
}
200200
}
201201

202-
protected static function handleNotifyFork(): void
202+
public static function handleNotifyFork(): void
203203
{
204+
if (!isset(static::$posixLoaded) && !isset(static::$extVersion)) {
205+
return;
206+
}
207+
204208
if (static::$prepareToForkPPID && \version_compare(static::$extVersion, '4.2.1', '>=')) {
205209
if (static::$prepareToForkPPID === \posix_getpid()) {
206210
Cluster::notifyFork(ForkEvent::PARENT);

tests/Couchbasev4.test.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@
8282
try {
8383
\Phpfastcache\Extensions\Drivers\Couchbasev4\Driver::prepareToFork();
8484
$pid = \pcntl_fork();
85+
\Phpfastcache\Extensions\Drivers\Couchbasev4\Driver::handleNotifyFork();
8586
if ($pid == -1) {
8687
$testHelper->assertFail('Unable to fork');
8788
} else if ($pid) {

0 commit comments

Comments
 (0)