mirror of
https://github.com/minio/minio.git
synced 2025-11-29 21:33:31 -05:00
Allow for proper garbage collection pooling bytes.Buffer (#6266)
This commit is contained in:
committed by
kannappanr
parent
1103ad2d08
commit
65de2d68c0
@@ -17,7 +17,6 @@
|
||||
package rpc
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"crypto/tls"
|
||||
"encoding/gob"
|
||||
@@ -48,22 +47,25 @@ func (client *Client) Call(serviceMethod string, args, reply interface{}) error
|
||||
return fmt.Errorf("rpc reply must be a pointer type, but found %v", replyKind)
|
||||
}
|
||||
|
||||
data, err := gobEncode(args)
|
||||
if err != nil {
|
||||
argBuf := bufPool.Get()
|
||||
defer bufPool.Put(argBuf)
|
||||
|
||||
if err := gobEncodeBuf(args, argBuf); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
callRequest := CallRequest{
|
||||
Method: serviceMethod,
|
||||
ArgBytes: data,
|
||||
ArgBytes: argBuf.Bytes(),
|
||||
}
|
||||
|
||||
var buf bytes.Buffer
|
||||
if err = gob.NewEncoder(&buf).Encode(callRequest); err != nil {
|
||||
reqBuf := bufPool.Get()
|
||||
defer bufPool.Put(reqBuf)
|
||||
if err := gob.NewEncoder(reqBuf).Encode(callRequest); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
response, err := client.httpClient.Post(client.serviceURL.String(), "", &buf)
|
||||
response, err := client.httpClient.Post(client.serviceURL.String(), "", reqBuf)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user