From 8c6ee24b16b5915090f58f437332bb5f24158c9c Mon Sep 17 00:00:00 2001 From: orgin Date: Sat, 26 Nov 2022 14:16:25 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96rpc?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- rpc/rpchandler.go | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/rpc/rpchandler.go b/rpc/rpchandler.go index 00605a6..ccf5fc7 100644 --- a/rpc/rpchandler.go +++ b/rpc/rpchandler.go @@ -273,7 +273,25 @@ func (handler *RpcHandler) HandlerRpcRequest(request *RpcRequest) { } } - paramList = append(paramList, reflect.ValueOf(request.inParam)) + //复制输入参数 + iParamValue := reflect.New(v.inParamValue.Type().Elem()) + iParam := iParamValue.Interface() + _, processor := GetProcessorType(request.inParam) + bytes,err := processor.Marshal(request.inParam) + if err == nil { + err = processor.Unmarshal(bytes,iParam) + } + + if err != nil { + errM := "RpcHandler " + handler.rpcHandler.GetName() + "."+ request.RpcRequestData.GetServiceMethod()+" deep copy inParam is error:" + err.Error() + log.SError(errM) + if request.requestHandle != nil { + request.requestHandle(nil, RpcError(errM)) + } + return + } + + paramList = append(paramList, iParamValue) var oParam reflect.Value if v.outParamValue.IsValid() { if request.localReply != nil { @@ -288,6 +306,7 @@ func (handler *RpcHandler) HandlerRpcRequest(request *RpcRequest) { request.requestHandle(nil, RpcError(rErr)) return } + returnValues := v.method.Func.Call(paramList) errInter := returnValues[0].Interface() if errInter != nil {