Prechádzať zdrojové kódy

Replace EV_SIGNAL to pcntl only.

Ares 7 rokov pred
rodič
commit
84d841f46e
1 zmenil súbory, kde vykonal 10 pridanie a 20 odobranie
  1. 10 20
      Events/Swoole.php

+ 10 - 20
Events/Swoole.php

@@ -24,11 +24,9 @@ class Swoole implements EventInterface
 
     protected $_fd = array();
 
-    // milisecond. Set to null will use swoole signal.
+    // milisecond
     public static $signalDispatchInterval = 200;
 
-    // Swoole\Process::signal() is not stable in some version of php and swoole.
-    // The problem may be caused by using pcntl_signal() and pcntl_fork() and Swoole\Process::signal() together.
     protected $_hasSignal = false;
 
     /**
@@ -44,19 +42,15 @@ class Swoole implements EventInterface
         }
         switch ($flag) {
             case self::EV_SIGNAL:
-                if (isset(static::$signalDispatchInterval)) {
-                    $res = pcntl_signal($fd, $func, false);
-                    if (! $this->_hasSignal && $res) {
-                        Timer::tick(static::$signalDispatchInterval,
-                            function () {
-                                pcntl_signal_dispatch();
-                            });
-                        $this->_hasSignal = true;
-                    }
-                    return $res;
-                } else {
-                    return Process::signal($fd, $func);
+                $res = pcntl_signal($fd, $func, false);
+                if (! $this->_hasSignal && $res) {
+                    Timer::tick(static::$signalDispatchInterval,
+                        function () {
+                            pcntl_signal_dispatch();
+                        });
+                    $this->_hasSignal = true;
                 }
+                return $res;
             case self::EV_TIMER:
             case self::EV_TIMER_ONCE:
                 $method = self::EV_TIMER == $flag ? 'tick' : 'after';
@@ -90,11 +84,7 @@ class Swoole implements EventInterface
     {
         switch ($flag) {
             case self::EV_SIGNAL:
-                if (isset(static::$signalDispatchInterval)) {
-                    return pcntl_signal($fd, SIG_IGN, false);
-                } else {
-                    return Process::signal($fd, null);
-                }
+                return pcntl_signal($fd, SIG_IGN, false);
             case self::EV_TIMER:
             case self::EV_TIMER_ONCE:
                 return Timer::clear($fd);