Commit 70fe7565 authored by AlexStocks's avatar AlexStocks

fix issue 77: process the last package before handle eof error

parent 54967137
......@@ -20,3 +20,6 @@ classes
*.swp
vendor/
# vscode
.vscode/
......@@ -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,12 +645,7 @@ func (s *session) handleTCPPackage() error {
}
break
}
if exit {
break
}
if 0 == bufLen {
continue // just continue if session can not read no more stream bytes.
}
if 0 != bufLen {
pktBuf.Write(buf[:bufLen])
for {
if pktBuf.Len() <= 0 {
......@@ -671,6 +673,7 @@ func (s *session) handleTCPPackage() error {
pktBuf.Next(pkgLen)
// continue to handle case 5
}
}
if exit {
break
}
......
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