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
70fe7565
Commit
70fe7565
authored
Oct 09, 2021
by
AlexStocks
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix issue 77: process the last package before handle eof error
parent
54967137
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
31 deletions
+37
-31
.gitignore
.gitignore
+3
-0
session.go
session.go
+34
-31
No files found.
.gitignore
View file @
70fe7565
...
...
@@ -20,3 +20,6 @@ classes
*.swp
vendor/
# vscode
.vscode/
session.go
View file @
70fe7565
...
...
@@ -631,6 +631,13 @@ func (s *session) handleTCPPackage() error {
log
.
Infof
(
"%s, session.conn read EOF, client send over, session exit"
,
s
.
sessionToken
())
err
=
nil
exit
=
true
if
bufLen
!=
0
{
// as https://github.com/apache/dubbo-getty/issues/77#issuecomment-939652203
// this branch is impossible. Even if it happens, the bufLen will be zero and the error
// is io.EOF when getty continues to read the socket.
exit
=
false
log
.
Infof
(
"%s, session.conn read EOF, while the bufLen(%d) is non-zero."
,
s
.
sessionToken
())
}
break
}
log
.
Errorf
(
"%s, [session.conn.read] = error:%+v"
,
s
.
sessionToken
(),
perrors
.
WithStack
(
err
))
...
...
@@ -638,38 +645,34 @@ func (s *session) handleTCPPackage() error {
}
break
}
if
exit
{
break
}
if
0
==
bufLen
{
continue
// just continue if session can not read no more stream bytes.
}
pktBuf
.
Write
(
buf
[
:
bufLen
])
for
{
if
pktBuf
.
Len
()
<=
0
{
break
}
pkg
,
pkgLen
,
err
=
s
.
reader
.
Read
(
s
,
pktBuf
.
Bytes
())
// for case 3/case 4
if
err
==
nil
&&
s
.
maxMsgLen
>
0
&&
pkgLen
>
int
(
s
.
maxMsgLen
)
{
err
=
perrors
.
Errorf
(
"pkgLen %d > session max message len %d"
,
pkgLen
,
s
.
maxMsgLen
)
}
// handle case 1
if
err
!=
nil
{
log
.
Warnf
(
"%s, [session.handleTCPPackage] = len{%d}, error:%+v"
,
s
.
sessionToken
(),
pkgLen
,
perrors
.
WithStack
(
err
))
exit
=
true
break
}
// handle case 2/case 3
if
pkg
==
nil
{
break
if
0
!=
bufLen
{
pktBuf
.
Write
(
buf
[
:
bufLen
])
for
{
if
pktBuf
.
Len
()
<=
0
{
break
}
pkg
,
pkgLen
,
err
=
s
.
reader
.
Read
(
s
,
pktBuf
.
Bytes
())
// for case 3/case 4
if
err
==
nil
&&
s
.
maxMsgLen
>
0
&&
pkgLen
>
int
(
s
.
maxMsgLen
)
{
err
=
perrors
.
Errorf
(
"pkgLen %d > session max message len %d"
,
pkgLen
,
s
.
maxMsgLen
)
}
// handle case 1
if
err
!=
nil
{
log
.
Warnf
(
"%s, [session.handleTCPPackage] = len{%d}, error:%+v"
,
s
.
sessionToken
(),
pkgLen
,
perrors
.
WithStack
(
err
))
exit
=
true
break
}
// handle case 2/case 3
if
pkg
==
nil
{
break
}
// handle case 4
s
.
UpdateActive
()
s
.
addTask
(
pkg
)
pktBuf
.
Next
(
pkgLen
)
// continue to handle case 5
}
// handle case 4
s
.
UpdateActive
()
s
.
addTask
(
pkg
)
pktBuf
.
Next
(
pkgLen
)
// continue to handle case 5
}
if
exit
{
break
...
...
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