Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ISSUE #757] Fix GetHeader type conflict #758

Merged
merged 1 commit into from
Dec 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions internal/remote/remote_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,13 +155,13 @@ func (c *remotingClient) receiveResponse(r *tcpConnWrapper) {
break
}

_, err = io.ReadFull(r, header)
_, err = io.ReadFull(r, *header)
if err != nil {
continue
}

var length int32
err = binary.Read(bytes.NewReader(header), binary.BigEndian, &length)
err = binary.Read(bytes.NewReader(*header), binary.BigEndian, &length)
if err != nil {
continue
}
Expand Down
11 changes: 6 additions & 5 deletions primitive/pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,21 +27,22 @@ var bufferPool = sync.Pool{}

func init() {
headerPool.New = func() interface{} {
return make([]byte, 4)
b := make([]byte, 4)
return &b
}
bufferPool.New = func() interface{} {
return new(bytes.Buffer)
}
}

func GetHeader() []byte {
d := headerPool.Get().([]byte)
func GetHeader() *[]byte {
d := headerPool.Get().(*[]byte)
//d = (d)[:0]
return d
}

func BackHeader(d []byte) {
headerPool.Put(&d)
func BackHeader(d *[]byte) {
headerPool.Put(d)
}

func GetBuffer() *bytes.Buffer {
Expand Down