Skip to content

Commit e45481c

Browse files
committed
Defer checks for ext/pcntl until instantiation
1 parent 534f807 commit e45481c

File tree

4 files changed

+29
-7
lines changed

4 files changed

+29
-7
lines changed

ChangeLog.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,13 @@ Networking changelog
33

44
## ?.?.? / ????-??-??
55

6+
## 10.3.1 / 2022-08-28
7+
8+
* Fixed package reflection for `peer.server` by deferring the check for
9+
`ext/pcntl` until server implementations based on its functionality
10+
are instantiated, not just loaded
11+
(@thekid)
12+
613
## 10.3.0 / 2022-08-26
714

815
* Merged PR #24: Simplify peer.net API, implementing features sugggested

src/main/php/peer/server/ForkingServer.class.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,19 @@
1010
*/
1111
class ForkingServer extends Server {
1212
use Pcntl;
13-
13+
14+
/**
15+
* Constructor
16+
*
17+
* @param string $addr
18+
* @param int $port
19+
* @throws lang.IllegalAccessException
20+
*/
21+
public function __construct($addr, $port) {
22+
self::extension();
23+
parent::__construct($addr, $port);
24+
}
25+
1426
/**
1527
* Service
1628
*

src/main/php/peer/server/Pcntl.class.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@
44

55
trait Pcntl {
66

7-
static function __static() {
7+
/** Verify PCNTL extension is loaded and useable */
8+
private static function extension() {
89
if (!extension_loaded('pcntl')) {
9-
throw new IllegalAccessException('PCNTL extension not available');
10+
throw new IllegalAccessException('PCNTL extension not loaded');
1011
}
1112

1213
// https://stackoverflow.com/questions/16262854/pcntl-not-working-on-ubuntu-for-security-reasons

src/main/php/peer/server/PreforkingServer.class.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,14 @@ class PreforkingServer extends Server implements Traceable {
2121
/**
2222
* Constructor
2323
*
24-
* @param string addr
25-
* @param int port
26-
* @param int count default 10 number of children to fork
27-
* @param int maxrequests default 1000 maxmimum # of requests per child
24+
* @param string $addr
25+
* @param int $port
26+
* @param int $count default 10 number of children to fork
27+
* @param int $maxrequests default 1000 maxmimum # of requests per child
28+
* @throws lang.IllegalAccessException
2829
*/
2930
public function __construct($addr, $port, $count= 10, $maxrequests= 1000) {
31+
self::extension();
3032
parent::__construct($addr, $port);
3133
$this->count= (int)$count;
3234
$this->maxrequests= (int)$maxrequests;

0 commit comments

Comments
 (0)