mirror of
https://github.com/duanhf2012/origin.git
synced 2026-02-04 06:54:45 +08:00
优化rpc
This commit is contained in:
@@ -268,8 +268,27 @@ func (server *Server) selfNodeRpcHandlerGo(processor IRpcProcessor, client *Clie
|
|||||||
if processor == nil {
|
if processor == nil {
|
||||||
_, processor = GetProcessorType(args)
|
_, processor = GetProcessorType(args)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inParamValue := reflect.New(reflect.ValueOf(args).Type().Elem())
|
||||||
|
//args
|
||||||
|
//复制输入参数
|
||||||
|
iParam := inParamValue.Interface()
|
||||||
|
bytes,err := processor.Marshal(args)
|
||||||
|
if err == nil {
|
||||||
|
err = processor.Unmarshal(bytes,iParam)
|
||||||
|
}
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
pCall.Seq = 0
|
||||||
|
pCall.Err = errors.New("RpcHandler " + handlerName + "."+serviceMethod+" deep copy inParam is error:" + err.Error())
|
||||||
|
pCall.done <- pCall
|
||||||
|
log.SError(pCall.Err.Error())
|
||||||
|
|
||||||
|
return pCall
|
||||||
|
}
|
||||||
|
|
||||||
req := MakeRpcRequest(processor, 0, rpcMethodId, serviceMethod, noReply, nil)
|
req := MakeRpcRequest(processor, 0, rpcMethodId, serviceMethod, noReply, nil)
|
||||||
req.inParam = args
|
req.inParam = iParam
|
||||||
req.localReply = reply
|
req.localReply = reply
|
||||||
if rawArgs != nil {
|
if rawArgs != nil {
|
||||||
var err error
|
var err error
|
||||||
@@ -316,7 +335,7 @@ func (server *Server) selfNodeRpcHandlerGo(processor IRpcProcessor, client *Clie
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
err := rpcHandler.PushRpcRequest(req)
|
err = rpcHandler.PushRpcRequest(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ReleaseRpcRequest(req)
|
ReleaseRpcRequest(req)
|
||||||
pCall.Err = err
|
pCall.Err = err
|
||||||
|
|||||||
Reference in New Issue
Block a user