walkor 9 жил өмнө
parent
commit
efbad6dc2b

+ 6 - 0
Connection/AsyncTcpConnection.php

@@ -111,6 +111,9 @@ class AsyncTcpConnection extends TcpConnection
             } catch (\Exception $e) {
                 echo $e;
                 exit(250);
+            } catch (\Error $e) {
+                echo $e;
+                exit(250);
             }
         }
     }
@@ -150,6 +153,9 @@ class AsyncTcpConnection extends TcpConnection
                 } catch (\Exception $e) {
                     echo $e;
                     exit(250);
+                } catch (\Error $e) {
+                    echo $e;
+                    exit(250);
                 }
             }
         } else {

+ 18 - 0
Connection/TcpConnection.php

@@ -261,6 +261,9 @@ class TcpConnection extends ConnectionInterface
                         } catch (\Exception $e) {
                             echo $e;
                             exit(250);
+                        } catch (\Error $e) {
+                            echo $e;
+                            exit(250);
                         }
                     }
                     $this->destroy();
@@ -420,6 +423,9 @@ class TcpConnection extends ConnectionInterface
                 } catch (\Exception $e) {
                     echo $e;
                     exit(250);
+                } catch (\Error $e) {
+                    echo $e;
+                    exit(250);
                 }
             }
             return;
@@ -440,6 +446,9 @@ class TcpConnection extends ConnectionInterface
         } catch (\Exception $e) {
             echo $e;
             exit(250);
+        } catch (\Error $e) {
+            echo $e;
+            exit(250);
         }
         // Clean receive buffer.
         $this->_recvBuffer = '';
@@ -463,6 +472,9 @@ class TcpConnection extends ConnectionInterface
                 } catch (\Exception $e) {
                     echo $e;
                     exit(250);
+                } catch (\Error $e) {
+                    echo $e;
+                    exit(250);
                 }
             }
             if ($this->_status === self::STATUS_CLOSING) {
@@ -557,6 +569,9 @@ class TcpConnection extends ConnectionInterface
                 } catch (\Exception $e) {
                     echo $e;
                     exit(250);
+                } catch (\Error $e) {
+                    echo $e;
+                    exit(250);
                 }
             }
         }
@@ -590,6 +605,9 @@ class TcpConnection extends ConnectionInterface
             } catch (\Exception $e) {
                 echo $e;
                 exit(250);
+            } catch (\Error $e) {
+                echo $e;
+                exit(250);
             }
         }
         // Cleaning up the callback to avoid memory leaks.

+ 6 - 0
Events/Ev.php

@@ -58,6 +58,9 @@ class Ev implements EventInterface
             } catch (\Exception $e) {
                 echo $e;
                 exit(250);
+            } catch (\Error $e) {
+                echo $e;
+                exit(250);
             }
         };
 
@@ -137,6 +140,9 @@ class Ev implements EventInterface
         } catch (\Exception $e) {
             echo $e;
             exit(250);
+        } catch (\Error $e) {
+            echo $e;
+            exit(250);
         }
     }
 

+ 3 - 0
Events/Event.php

@@ -157,6 +157,9 @@ class Event implements EventInterface
         } catch (\Exception $e) {
             echo $e;
             exit(250);
+        } catch (\Error $e) {
+            echo $e;
+            exit(250);
         }
     }
     

+ 3 - 0
Events/Libevent.php

@@ -172,6 +172,9 @@ class Libevent implements EventInterface
         } catch (\Exception $e) {
             echo $e;
             exit(250);
+        } catch (\Error $e) {
+            echo $e;
+            exit(250);
         }
         if (isset($this->_eventTimer[$timer_id]) && $this->_eventTimer[$timer_id][3] === self::EV_TIMER_ONCE) {
             $this->del($timer_id, self::EV_TIMER_ONCE);

+ 9 - 1
Lib/Constants.php

@@ -24,4 +24,12 @@ error_reporting(E_ALL);
 // For onError callback.
 define('WORKERMAN_CONNECT_FAIL', 1);
 // For onError callback.
-define('WORKERMAN_SEND_FAIL', 2);
+define('WORKERMAN_SEND_FAIL', 2);
+
+// Compatible with php7
+if(!class_exists('Error''))
+{
+    class Error extends Exception
+    {
+    }
+}

+ 12 - 0
Protocols/Websocket.php

@@ -92,6 +92,9 @@ class Websocket implements \Workerman\Protocols\ProtocolInterface
                         } catch (\Exception $e) {
                             echo $e;
                             exit(250);
+                        } catch (\Error $e) {
+                            echo $e;
+                            exit(250);
                         }
                     } // Close connection.
                     else {
@@ -107,6 +110,9 @@ class Websocket implements \Workerman\Protocols\ProtocolInterface
                         } catch (\Exception $e) {
                             echo $e;
                             exit(250);
+                        } catch (\Error $e) {
+                            echo $e;
+                            exit(250);
                         }
                     } // Send pong package to client.
                     else {
@@ -131,6 +137,9 @@ class Websocket implements \Workerman\Protocols\ProtocolInterface
                         } catch (\Exception $e) {
                             echo $e;
                             exit(250);
+                        } catch (\Error $e) {
+                            echo $e;
+                            exit(250);
                         }
                     }
                     //  Consume data from receive buffer.
@@ -339,6 +348,9 @@ class Websocket implements \Workerman\Protocols\ProtocolInterface
                 } catch (\Exception $e) {
                     echo $e;
                     exit(250);
+                } catch (\Error $e) {
+                    echo $e;
+                    exit(250);
                 }
                 $_GET = $_COOKIE = $_SERVER = array();
             }

+ 13 - 1
Protocols/Ws.php

@@ -78,6 +78,9 @@ class Ws
                         } catch (\Exception $e) {
                             echo $e;
                             exit(250);
+                        } catch (\Error $e) {
+                            echo $e;
+                            exit(250);
                         }
                     } // Close connection.
                     else {
@@ -93,6 +96,9 @@ class Ws
                         } catch (\Exception $e) {
                             echo $e;
                             exit(250);
+                        } catch (\Error $e) {
+                            echo $e;
+                            exit(250);
                         }
                     } // Send pong package to client.
                     else {
@@ -116,6 +122,9 @@ class Ws
                         } catch (\Exception $e) {
                             echo $e;
                             exit(250);
+                        } catch (\Error $e) {
+                            echo $e;
+                            exit(250);
                         }
                     }
                     //  Consume data from receive buffer.
@@ -194,7 +203,7 @@ class Ws
         $pack = '';
         $length = $length_flag = strlen($payload);
         if (65535 < $length) {
-            $pack   = pack('NN', ($length & 0xFFFFFFFF00000000) >> 0b100000, $length & 0x00000000FFFFFFFF);
+            $pack   = pack('NN', ($length & 0xFFFFFFFF00000000) >> 32, $length & 0x00000000FFFFFFFF);
             $length_flag = 127;
         } else if (125 < $length) {
             $pack   = pack('n*', $length);
@@ -312,6 +321,9 @@ class Ws
                 } catch (\Exception $e) {
                     echo $e;
                     exit(250);
+                } catch (\Error $e) {
+                    echo $e;
+                    exit(250);
                 }
             }
             // Headbeat.

+ 3 - 0
WebServer.php

@@ -110,6 +110,9 @@ class WebServer extends Worker
             } catch (\Exception $e) {
                 echo $e;
                 exit(250);
+            } catch (\Error $e) {
+                echo $e;
+                exit(250);
             }
         }
     }

+ 16 - 1
Worker.php

@@ -33,7 +33,7 @@ class Worker
      *
      * @var string
      */
-    const VERSION = '3.3.1';
+    const VERSION = '3.3.2';
 
     /**
      * Status starting.
@@ -1110,6 +1110,9 @@ class Worker
                 } catch (\Exception $e) {
                     echo $e;
                     exit(250);
+                } catch (\Error $e) {
+                    echo $e;
+                    exit(250);
                 }
             }
 
@@ -1457,6 +1460,9 @@ class Worker
             } catch (\Exception $e) {
                 echo $e;
                 exit(250);
+            } catch (\Error $e) {
+                echo $e;
+                exit(250);
             }
         }
 
@@ -1478,6 +1484,9 @@ class Worker
             } catch (\Exception $e) {
                 echo $e;
                 exit(250);
+            } catch (\Error $e) {
+                echo $e;
+                exit(250);
             }
         }
         // Remove listener for server socket.
@@ -1518,6 +1527,9 @@ class Worker
             } catch (\Exception $e) {
                 echo $e;
                 exit(250);
+            } catch (\Error $e) {
+                echo $e;
+                exit(250);
             }
         }
     }
@@ -1548,6 +1560,9 @@ class Worker
             } catch (\Exception $e) {
                 echo $e;
                 exit(250);
+            } catch (\Error $e) {
+                echo $e;
+                exit(250);
             }
         }
         return true;