walkor vor 11 Jahren
Ursprung
Commit
1a94e4ab3d

+ 8 - 1
applications/Demo/Lib/StoreDriver/File.php

@@ -32,7 +32,14 @@ class File
         $this->dataFile = \Config\Store::$storePath . "/$config_name.store.cache.php";
         if(!is_dir(\Config\Store::$storePath) && !mkdir(\Config\Store::$storePath, 0777, true))
         {
-            throw new \Exception('cant not mkdir('.\Config\Store::$storePath.')');
+            // 可能目录已经被其它进程创建
+            clearstatcache();
+            if(!is_dir(\Config\Store::$storePath))
+            {
+                // 避免狂刷日志
+                sleep(1);
+                throw new \Exception('cant not mkdir('.\Config\Store::$storePath.')');
+            }
         }
         if(!is_file($this->dataFile))
         {

+ 8 - 1
applications/Demo/Protocols/WebSocket.php

@@ -13,6 +13,14 @@ class WebSocket
      */
     public static function check($buffer)
     {
+        // 数据长度
+        $recv_len = strlen($buffer);
+        // 长度不够
+        if($recv_len < 6)
+        {
+            return 6-$recv_len;
+        }
+        
         // 握手阶段客户端发送HTTP协议
         if(0 === strpos($buffer, 'GET'))
         {
@@ -34,7 +42,6 @@ class WebSocket
         }
         
         // websocket二进制数据
-        $recv_len = strlen($buffer);
         $data_len = ord($buffer[1]) & 127;
         $head_len = 6;
         if ($data_len === 126) {