Skip to content

Commit

Permalink
Merge pull request #81 from apache/feature/gxbytes-buffer
Browse files Browse the repository at this point in the history
Imp: using gxbytes.Buffer WriteNextBegin/WriteNextEnd
  • Loading branch information
AlexStocks authored Oct 28, 2021
2 parents 66f2506 + 43cebf1 commit a2461f8
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 11 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/apache/dubbo-getty
go 1.14

require (
github.com/dubbogo/gost v1.11.12
github.com/dubbogo/gost v1.11.19
github.com/golang/snappy v0.0.1
github.com/gorilla/websocket v1.4.2
github.com/montanaflynn/stats v0.6.6
Expand Down
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,6 @@ github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs
github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ=
github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no=
github.com/dubbogo/go-zookeeper v1.0.3/go.mod h1:fn6n2CAEer3novYgk9ULLwAjuV8/g4DdC2ENwRb6E+c=
github.com/dubbogo/gost v1.11.12 h1:e3861DxHWe509whpMxS6mFBmgmm7r9+bT5iJ/PRufcw=
github.com/dubbogo/gost v1.11.12/go.mod h1:vIcP9rqz2KsXHPjsAwIUtfJIJjppQLQDcYaZTy/61jI=
github.com/dubbogo/gost v1.11.19 h1:R1rZ3TNJKV9W5XHLMv+GDO2Wy6UDnwGQtVWbsWYvo0A=
github.com/dubbogo/gost v1.11.19/go.mod h1:vIcP9rqz2KsXHPjsAwIUtfJIJjppQLQDcYaZTy/61jI=
github.com/dubbogo/jsonparser v1.0.1/go.mod h1:tYAtpctvSP/tWw4MeelsowSPgXQRVHHWbqL6ynps8jU=
Expand Down
12 changes: 4 additions & 8 deletions session.go
Original file line number Diff line number Diff line change
Expand Up @@ -597,17 +597,12 @@ func (s *session) handleTCPPackage() error {
exit bool
bufLen int
pkgLen int
bufp *[]byte
buf []byte
pktBuf *bytes.Buffer
pktBuf *gxbytes.Buffer
pkg interface{}
)

// buf = make([]byte, maxReadBufLen)
bufp = gxbytes.GetBytes(maxReadBufLen)
buf = *bufp

pktBuf = new(bytes.Buffer)
pktBuf = gxbytes.NewBuffer(nil)

conn = s.Connection.(*gettyTCPConn)
for {
Expand All @@ -622,6 +617,7 @@ func (s *session) handleTCPPackage() error {
for {
// for clause for the network timeout condition check
// s.conn.SetReadTimeout(time.Now().Add(s.rTimeout))
buf = pktBuf.WriteNextBegin(maxReadBufLen)
bufLen, err = conn.recv(buf)
if err != nil {
if netError, ok = perrors.Cause(err).(net.Error); ok && netError.Timeout() {
Expand All @@ -646,7 +642,7 @@ func (s *session) handleTCPPackage() error {
break
}
if 0 != bufLen {
pktBuf.Write(buf[:bufLen])
pktBuf.WriteNextEnd(bufLen)
for {
if pktBuf.Len() <= 0 {
break
Expand Down

0 comments on commit a2461f8

Please sign in to comment.