Skip to content

Commit 95146a5

Browse files
committed
Bugfix
1 parent d1498a8 commit 95146a5

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

lib/BoundTCPSocket.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public function bindSocket() {
5959
return false;
6060
}
6161
$port = isset($this->uri['port']) ? $this->uri['port'] : $this->defaultPort;
62-
if (($port < 1024) && Daemon::$config->user !== 'root') {
62+
if (($port < 1024) && Daemon::$config->user->value !== 'root') {
6363
$this->listenerMode = false;
6464
}
6565
if ($this->listenerMode) {

lib/Daemon.php

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ class Daemon {
1919
const WSTATE_PREINIT = 4;
2020
const WSTATE_WAITINIT = 5;
2121
const WSTATE_INIT = 6;
22+
2223
public static $wstateRev = [
2324
1 => 'IDLE',
2425
2 => 'BUSY',
@@ -64,7 +65,13 @@ class Daemon {
6465
protected static $masters;
6566
protected static $initservervar;
6667
public static $shm_wstate;
67-
public static $reusePort;
68+
69+
/**
70+
* Сurrently re-using bound ports across multiple processes is available
71+
* only in BSD flavour operating systems via SO_REUSEPORT socket option
72+
* @var boolean
73+
*/
74+
public static $reusePort = false;
6875
public static $compatMode = FALSE;
6976
public static $runName = 'phpdaemon';
7077
public static $config;
@@ -85,12 +92,12 @@ public static function initSettings() {
8592

8693
Daemon::$config = new Daemon_Config;
8794

88-
// currently re-using listener ports across multiple processes is available
89-
// only in BSD flavour operating systems via SO_REUSEPORT socket option
90-
Daemon::$reusePort = 1 === preg_match("~BSD~i", php_uname('s'));
95+
if (preg_match('~BSD~i', php_uname('s'))) {
96+
Daemon::$reusePort = true;
97+
}
9198

9299
if (Daemon::$reusePort && !defined("SO_REUSEPORT"))
93-
define("SO_REUSEPORT", 0x200); // FIXME: this is a BSD-only hack
100+
define("SO_REUSEPORT", 0x200); // @TODO: FIXME: this is a BSD-only hack
94101
}
95102

96103
public static function loadModuleIfAbsent($mod, $version = null, $compare = '>=') {

0 commit comments

Comments
 (0)