|
@@ -96,8 +96,8 @@ class Select implements EventInterface
|
|
|
public function __construct()
|
|
public function __construct()
|
|
|
{
|
|
{
|
|
|
// Create a pipeline and put into the collection of the read to read the descriptor to avoid empty polling.
|
|
// Create a pipeline and put into the collection of the read to read the descriptor to avoid empty polling.
|
|
|
- $this->channel = \stream_socket_pair(DIRECTORY_SEPARATOR === '/' ? STREAM_PF_UNIX : STREAM_PF_INET,
|
|
|
|
|
- STREAM_SOCK_STREAM, STREAM_IPPROTO_IP);
|
|
|
|
|
|
|
+ $this->channel = \stream_socket_pair(\DIRECTORY_SEPARATOR === '/' ? \STREAM_PF_UNIX : \STREAM_PF_INET,
|
|
|
|
|
+ \STREAM_SOCK_STREAM, \STREAM_IPPROTO_IP);
|
|
|
if($this->channel) {
|
|
if($this->channel) {
|
|
|
\stream_set_blocking($this->channel[0], 0);
|
|
\stream_set_blocking($this->channel[0], 0);
|
|
|
$this->_readFds[0] = $this->channel[0];
|
|
$this->_readFds[0] = $this->channel[0];
|
|
@@ -118,7 +118,7 @@ class Select implements EventInterface
|
|
|
$count = $flag === self::EV_READ ? \count($this->_readFds) : \count($this->_writeFds);
|
|
$count = $flag === self::EV_READ ? \count($this->_readFds) : \count($this->_writeFds);
|
|
|
if ($count >= 1024) {
|
|
if ($count >= 1024) {
|
|
|
echo "Warning: system call select exceeded the maximum number of connections 1024, please install event/libevent extension for more connections.\n";
|
|
echo "Warning: system call select exceeded the maximum number of connections 1024, please install event/libevent extension for more connections.\n";
|
|
|
- } else if (DIRECTORY_SEPARATOR !== '/' && $count >= 256) {
|
|
|
|
|
|
|
+ } else if (\DIRECTORY_SEPARATOR !== '/' && $count >= 256) {
|
|
|
echo "Warning: system call select exceeded the maximum number of connections 256.\n";
|
|
echo "Warning: system call select exceeded the maximum number of connections 256.\n";
|
|
|
}
|
|
}
|
|
|
$fd_key = (int)$fd;
|
|
$fd_key = (int)$fd;
|
|
@@ -136,7 +136,7 @@ class Select implements EventInterface
|
|
|
break;
|
|
break;
|
|
|
case self::EV_SIGNAL:
|
|
case self::EV_SIGNAL:
|
|
|
// Windows not support signal.
|
|
// Windows not support signal.
|
|
|
- if(DIRECTORY_SEPARATOR !== '/') {
|
|
|
|
|
|
|
+ if(\DIRECTORY_SEPARATOR !== '/') {
|
|
|
return false;
|
|
return false;
|
|
|
}
|
|
}
|
|
|
$fd_key = (int)$fd;
|
|
$fd_key = (int)$fd;
|
|
@@ -196,7 +196,7 @@ class Select implements EventInterface
|
|
|
}
|
|
}
|
|
|
return true;
|
|
return true;
|
|
|
case self::EV_SIGNAL:
|
|
case self::EV_SIGNAL:
|
|
|
- if(DIRECTORY_SEPARATOR !== '/') {
|
|
|
|
|
|
|
+ if(\DIRECTORY_SEPARATOR !== '/') {
|
|
|
return false;
|
|
return false;
|
|
|
}
|
|
}
|
|
|
unset($this->_signalEvents[$fd_key]);
|
|
unset($this->_signalEvents[$fd_key]);
|
|
@@ -263,7 +263,7 @@ class Select implements EventInterface
|
|
|
public function loop()
|
|
public function loop()
|
|
|
{
|
|
{
|
|
|
while (1) {
|
|
while (1) {
|
|
|
- if(DIRECTORY_SEPARATOR === '/') {
|
|
|
|
|
|
|
+ if(\DIRECTORY_SEPARATOR === '/') {
|
|
|
// Calls signal handlers for pending signals
|
|
// Calls signal handlers for pending signals
|
|
|
\pcntl_signal_dispatch();
|
|
\pcntl_signal_dispatch();
|
|
|
}
|
|
}
|