Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
W
wxh_internal_api
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
杨培培
wxh_internal_api
Commits
b73ae482
Commit
b73ae482
authored
Jan 13, 2020
by
杨培
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
针对 JSON RPC 错误返回导致内存溢出的情况做了优化
parent
24924bf5
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
2 deletions
+5
-2
JsonRpc.php
src/base/JsonRpc.php
+4
-1
client_config_dev.php
src/client_config_dev.php
+1
-1
No files found.
src/base/JsonRpc.php
View file @
b73ae482
...
@@ -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'
]);
...
...
src/client_config_dev.php
View file @
b73ae482
...
@@ -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'
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment