Browse Source

Merge pull request #2 from walkor/master

pull the latest version
blogdaren 5 years ago
parent
commit
1b59ee40ad
3 changed files with 17 additions and 14 deletions
  1. 9 11
      Events/Select.php
  2. 3 1
      README.md
  3. 5 2
      Worker.php

+ 9 - 11
Events/Select.php

@@ -95,13 +95,6 @@ class Select implements EventInterface
      */
     public function __construct()
     {
-        // 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);
-        if($this->channel) {
-            \stream_set_blocking($this->channel[0], 0);
-            $this->_readFds[0] = $this->channel[0];
-        }
         // Init SplPriorityQueue.
         $this->_scheduler = new \SplPriorityQueue();
         $this->_scheduler->setExtractFlags(\SplPriorityQueue::EXTR_BOTH);
@@ -272,10 +265,15 @@ class Select implements EventInterface
             $write = $this->_writeFds;
             $except = $this->_exceptFds;
 
-            // Waiting read/write/signal/timeout events.
-            \set_error_handler(function(){});
-            $ret = \stream_select($read, $write, $except, 0, $this->_selectTimeout);
-            \restore_error_handler();
+            if ($read || $write || $except) {
+                // Waiting read/write/signal/timeout events.
+                set_error_handler(function(){});
+                $ret = stream_select($read, $write, $except, 0, $this->_selectTimeout);
+                restore_error_handler();
+            } else {
+                usleep($this->_selectTimeout);
+                $ret = false;
+            }
 
 
             if (!$this->_scheduler->isEmpty()) {

+ 3 - 1
README.md

@@ -7,7 +7,9 @@
 [![License](https://poser.pugx.org/workerman/workerman/license)](https://packagist.org/packages/workerman/workerman)
 
 ## What is it
-Workerman is an asynchronous event driven PHP framework with high performance for easily building fast, scalable network applications. Supports HTTP, Websocket, SSL and other custom protocols. Supports libevent/event extension, [HHVM](https://github.com/facebook/hhvm) , [ReactPHP](https://github.com/reactphp/react).
+Workerman is an asynchronous event-driven PHP framework with high performance to build fast and scalable network applications. 
+Workerman supports HTTP, Websocket, SSL and other custom protocols. 
+Workerman supports libevent/event extension, [HHVM](https://github.com/facebook/hhvm) , [ReactPHP](https://github.com/reactphp/react).
 
 ## Requires
 PHP 5.3 or Higher  

+ 5 - 2
Worker.php

@@ -33,7 +33,7 @@ class Worker
      *
      * @var string
      */
-    const VERSION = '3.5.23';
+    const VERSION = '3.5.25';
 
     /**
      * Status starting.
@@ -615,7 +615,7 @@ class Worker
     protected static function lock()
     {
         $fd = \fopen(static::$_startFile, 'r');
-        if (!$fd || !flock($fd, LOCK_EX)) {
+        if ($fd && !flock($fd, LOCK_EX)) {
             static::log('Workerman['.static::$_startFile.'] already running.');
             exit;
         }
@@ -2142,6 +2142,9 @@ class Worker
             return false;
         }
         $stat = \fstat($stream);
+        if (!$stat) {
+            return false;
+        }
         if (($stat['mode'] & 0170000) === 0100000) {
             // file
             static::$_outputDecorated = false;