Browse Source

fix close

walkor 10 years ago
parent
commit
0aecdaf02c
4 changed files with 20 additions and 3 deletions
  1. 2 0
      GatewayWorker/Lib/Store.php
  2. 8 1
      Workerman/Connection/TcpConnection.php
  3. 0 2
      Workerman/Worker.php
  4. 10 0
      start.php

+ 2 - 0
GatewayWorker/Lib/Store.php

@@ -57,6 +57,8 @@ class Store
         {
             if(!isset(self::$instance[$config_name]))
             {
+                // 关闭opcache
+                ini_set('opcache.enable', false);
                 self::$instance[$config_name] = new \GatewayWorker\Lib\StoreDriver\File($config_name);
             }
             return self::$instance[$config_name];

+ 8 - 1
Workerman/Connection/TcpConnection.php

@@ -499,11 +499,18 @@ class TcpConnection extends ConnectionInterface
      */
     public function close($data = null)
     {
+        if($this->_status == self::STATUS_CLOSING)
+        {
+            return false;
+        }
+        else
+        {
+            $this->_status = self::STATUS_CLOSING;
+        }
         if($data !== null)
         {
             $this->send($data);
         }
-        $this->_status = self::STATUS_CLOSING;
         if($this->_sendBuffer === '')
         {
            $this->destroy();

+ 0 - 2
Workerman/Worker.php

@@ -328,8 +328,6 @@ class Worker
      */
     public static function init()
     {
-        // 关闭opcache
-        ini_set('opcache.enable', false);
         // 如果没设置$pidFile,则生成默认值
         if(empty(self::$pidFile))
         {

+ 10 - 0
start.php

@@ -7,6 +7,16 @@
 ini_set('display_errors', 'on');
 use Workerman\Worker;
 
+if(!extension_loaded('pcntl'))
+{
+    exit("Please install pcntl extension. See http://doc3.workerman.net/install/install.html\n");
+}
+
+if(!extension_loaded('posix'))
+{
+    exit("Please install posix extension. See http://doc3.workerman.net/install/install.html\n");
+}
+
 require_once __DIR__ . '/Workerman/Autoloader.php';
 
 foreach(glob(__DIR__.'/Applications/*/start.php') as $start_file)