Unverified Commit a2461f81 authored by Xin.Zh's avatar Xin.Zh Committed by GitHub

Merge pull request #81 from apache/feature/gxbytes-buffer

Imp: using gxbytes.Buffer WriteNextBegin/WriteNextEnd
parents 66f25061 43cebf12
......@@ -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
......
......@@ -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=
......
......@@ -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 {
......@@ -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() {
......@@ -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
......
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