diff --git a/rpc/rpc.go b/rpc/rpc.go index 296f496..92d0547 100644 --- a/rpc/rpc.go +++ b/rpc/rpc.go @@ -144,7 +144,7 @@ func (call *Call) Done() *Call{ } func MakeRpcRequest(rpcProcessor IRpcProcessor,seq uint64,rpcMethodId uint32,serviceMethod string,noReply bool,inParam []byte) *RpcRequest{ - rpcRequest := rpcRequestPool.Get().(*RpcRequest).Clear() + rpcRequest := rpcRequestPool.Get().(*RpcRequest) rpcRequest.rpcProcessor = rpcProcessor rpcRequest.RpcRequestData = rpcRequest.rpcProcessor.MakeRpcRequest(seq,rpcMethodId,serviceMethod,noReply,inParam) diff --git a/rpc/rpchandler.go b/rpc/rpchandler.go index 8e365e0..6b73ff7 100644 --- a/rpc/rpchandler.go +++ b/rpc/rpchandler.go @@ -243,12 +243,12 @@ func (handler *RpcHandler) HandlerRpcRequest(request *RpcRequest) { request.requestHandle(nil,rpcErr) } } - - if request.requestHandle == nil { - ReleaseRpcRequest(request) - } }() + if request.requestHandle == nil { + defer ReleaseRpcRequest(request) + } + //如果是原始RPC请求 rawRpcId := request.RpcRequestData.GetRpcMethodId() if rawRpcId>0 { diff --git a/util/sync/MemPool.go b/util/sync/MemPool.go index 4a97b70..ace1748 100644 --- a/util/sync/MemPool.go +++ b/util/sync/MemPool.go @@ -1,6 +1,8 @@ package sync -import sysSync "sync" +import ( + sysSync "sync" +) type Pool struct { C chan interface{} //最大缓存的数量 @@ -36,6 +38,7 @@ func (pool *Pool) Put(data interface{}){ default: pool.syncPool.Put(data) } + } func NewPool(C chan interface{},New func()interface{}) *Pool{