Commit b73ae482 authored by 杨培's avatar 杨培

针对 JSON RPC 错误返回导致内存溢出的情况做了优化

parent 24924bf5
...@@ -166,7 +166,6 @@ class JsonRpc ...@@ -166,7 +166,6 @@ class JsonRpc
* Reads a packet from the socket. Prior to reading from the socket * Reads a packet from the socket. Prior to reading from the socket
* will check for availability of the connection. * will check for availability of the connection.
* *
* @param integer $length Number of bytes to read.
* @return string|boolean Data or `false` on error. * @return string|boolean Data or `false` on error.
*/ */
protected function _read() { protected function _read() {
...@@ -186,6 +185,10 @@ class JsonRpc ...@@ -186,6 +185,10 @@ class JsonRpc
} elseif ($length == 0) { } elseif ($length == 0) {
$unpack = unpack('Nlen', substr($data, 0, $this->_config['frame_head_length'])); $unpack = unpack('Nlen', substr($data, 0, $this->_config['frame_head_length']));
$length = $unpack['len'] + $this->_config['frame_head_length']; //package length $length = $unpack['len'] + $this->_config['frame_head_length']; //package length
if ($length > 33554432) {
//限制最多传输 32M 内容,防止溢出
throw new RuntimeException("Read packet size is too large, server responed: \r\n".$data);
}
} }
} }
return substr($data, $this->_config['frame_head_length']); return substr($data, $this->_config['frame_head_length']);
......
...@@ -11,7 +11,7 @@ return [ ...@@ -11,7 +11,7 @@ return [
'apiUrl' => 'http://u.yunya.com/api/server', 'apiUrl' => 'http://u.yunya.com/api/server',
'clientId' => 'common', 'clientId' => 'common',
'clientSecret' => 'Kuy2dVHKRWKAFRXX2l6k', 'clientSecret' => 'Kuy2dVHKRWKAFRXX2l6k',
'rpcServer' => '192.168.99.185:9503' 'rpcServer' => '192.168.99.4:30186'
], ],
'xue' => [ 'xue' => [
'apiUrl' => 'http://xue.yunya.com/api', 'apiUrl' => 'http://xue.yunya.com/api',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment