Skip to content

Commit a8630de

Browse files
committed
Merge branch 'master' into refactor/async-server
2 parents 640b2ef + e45481c commit a8630de

6 files changed

+35
-13
lines changed

ChangeLog.md

+7
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

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Basic low-level
1515

1616
```php
1717
package peer {
18-
public enum peer.Sockets
18+
public abstract enum peer.Sockets
1919

2020
public class peer.AuthenticationException
2121
public class peer.BSDSocket
@@ -41,7 +41,7 @@ Networks and DNS
4141

4242
```php
4343
package peer.net {
44-
public interface peer.net.InetAddress
44+
public abstract class peer.net.InetAddress
4545

4646
public class peer.net.Inet4Address
4747
public class peer.net.Inet6Address

src/main/php/peer/Socket.class.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,12 @@ class Socket implements Channel, Value {
2929
* as value for the parameter "host", you must enclose the IP in
3030
* square brackets.
3131
*
32-
* @param string host hostname or IP address
33-
* @param int port
34-
* @param resource socket default NULL
32+
* @param string|peer.net.InetAddress $host either hostname or an IP address
33+
* @param int $port
34+
* @param resource $socket default NULL
3535
*/
3636
public function __construct($host, $port, $socket= null) {
37-
$this->host= $host;
37+
$this->host= (string)$host;
3838
$this->port= $port;
3939
$this->_sock= $socket;
4040
$this->context= stream_context_create();

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

+13-1
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

+3-2
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

+6-4
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)