Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
G
getty
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wei.xuan
getty
Commits
a414ed40
Commit
a414ed40
authored
Aug 17, 2018
by
AlexStocks
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix: do not unmarhsal empty body package like heatbeat package
parent
8899b0c0
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
4 deletions
+4
-4
codec.go
rpc/codec.go
+4
-4
No files found.
rpc/codec.go
View file @
a414ed40
...
...
@@ -272,7 +272,7 @@ func (p *GettyPackage) Unmarshal(buf *bytes.Buffer) (int, error) {
return
0
,
ErrTooLargePackage
}
if
bufLen
>=
totalLen
{
if
bufLen
>=
totalLen
&&
p
.
H
.
PkgLen
!=
0
{
if
err
:=
p
.
B
.
Unmarshal
(
p
.
H
.
CodecType
,
bytes
.
NewBuffer
(
buf
.
Next
(
int
(
p
.
H
.
PkgLen
))));
err
!=
nil
{
return
0
,
jerrors
.
Trace
(
err
)
}
...
...
@@ -345,7 +345,7 @@ func (req *GettyRPCRequest) Marshal(sz CodecType, buf *bytes.Buffer) (int, error
return
2
+
len
(
headerData
)
+
2
+
len
(
bodyData
),
nil
}
func
(
req
*
GettyRPCRequest
)
Unmarshal
(
sz
CodecType
,
buf
*
bytes
.
Buffer
)
error
{
func
(
req
*
GettyRPCRequest
)
Unmarshal
(
ct
CodecType
,
buf
*
bytes
.
Buffer
)
error
{
var
headerLen
uint16
err
:=
binary
.
Read
(
buf
,
binary
.
LittleEndian
,
&
headerLen
)
if
err
!=
nil
{
...
...
@@ -370,9 +370,9 @@ func (req *GettyRPCRequest) Unmarshal(sz CodecType, buf *bytes.Buffer) error {
return
jerrors
.
Trace
(
err
)
}
codec
:=
Codecs
[
sz
]
codec
:=
Codecs
[
ct
]
if
codec
==
nil
{
return
jerrors
.
Errorf
(
"can not find codec for %d"
,
sz
)
return
jerrors
.
Errorf
(
"can not find codec for %d"
,
ct
)
}
err
=
codec
.
Decode
(
header
,
&
req
.
header
)
...
...
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