You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dubbo.apache.org by al...@apache.org on 2021/10/09 15:12:04 UTC

[dubbo-getty] branch fix/issue-77 created (now 0afe149)

This is an automated email from the ASF dual-hosted git repository.

alexstocks pushed a change to branch fix/issue-77
in repository https://gitbox.apache.org/repos/asf/dubbo-getty.git.


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

This branch includes the following new commits:

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

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


[dubbo-getty] 01/01: fix issue 77: process the last package before handle eof error

Posted by al...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

alexstocks pushed a commit to branch fix/issue-77
in repository https://gitbox.apache.org/repos/asf/dubbo-getty.git

commit 0afe1497588f673301f248139db3dba6ca3569a4
Author: AlexStocks <al...@foxmail.com>
AuthorDate: Sat Oct 9 23:10:06 2021 +0800

    fix issue 77: process the last package before handle eof error
---
 .vscode/settings.json |  3 +++
 session.go            | 58 ++++++++++++++++++++++++---------------------------
 2 files changed, 30 insertions(+), 31 deletions(-)

diff --git a/.vscode/settings.json b/.vscode/settings.json
new file mode 100644
index 0000000..a460645
--- /dev/null
+++ b/.vscode/settings.json
@@ -0,0 +1,3 @@
+{
+    "go.inferGopath": false
+}
\ No newline at end of file
diff --git a/session.go b/session.go
index 3c4fd03..57af46a 100644
--- a/session.go
+++ b/session.go
@@ -638,38 +638,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