mirror of
https://github.com/duanhf2012/origin.git
synced 2026-02-03 22:45:13 +08:00
优化rpc返回参数与请求参数不一致时报错
This commit is contained in:
@@ -41,7 +41,10 @@ func (slf *GoGoPBProcessor) Marshal(v interface{}) ([]byte, error){
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (slf *GoGoPBProcessor) Unmarshal(data []byte, msg interface{}) error{
|
func (slf *GoGoPBProcessor) Unmarshal(data []byte, msg interface{}) error{
|
||||||
protoMsg := msg.(proto.Message)
|
protoMsg,ok := msg.(proto.Message)
|
||||||
|
if ok == false {
|
||||||
|
return fmt.Errorf("%+v is not of proto.Message type",msg)
|
||||||
|
}
|
||||||
return proto.Unmarshal(data, protoMsg)
|
return proto.Unmarshal(data, protoMsg)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -147,7 +147,6 @@ func (agent *RpcAgent) Run() {
|
|||||||
ReleaseRpcRequest(req)
|
ReleaseRpcRequest(req)
|
||||||
continue
|
continue
|
||||||
} else {
|
} else {
|
||||||
//will close tcpconn
|
|
||||||
ReleaseRpcRequest(req)
|
ReleaseRpcRequest(req)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
@@ -303,21 +302,22 @@ func (server *Server) selfNodeRpcHandlerGo(processor IRpcProcessor, client *Clie
|
|||||||
if reply != nil && Returns != reply && Returns != nil {
|
if reply != nil && Returns != reply && Returns != nil {
|
||||||
byteReturns, err := req.rpcProcessor.Marshal(Returns)
|
byteReturns, err := req.rpcProcessor.Marshal(Returns)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.SError("returns data cannot be marshal ", callSeq)
|
Err = ConvertError(err)
|
||||||
ReleaseRpcRequest(req)
|
log.SError("returns data cannot be marshal,callSeq is ", callSeq," error is ",err.Error())
|
||||||
}
|
}else{
|
||||||
|
err = req.rpcProcessor.Unmarshal(byteReturns, reply)
|
||||||
err = req.rpcProcessor.Unmarshal(byteReturns, reply)
|
if err != nil {
|
||||||
if err != nil {
|
Err = ConvertError(err)
|
||||||
log.SError("returns data cannot be Unmarshal ", callSeq)
|
log.SError("returns data cannot be Unmarshal,callSeq is ", callSeq," error is ",err.Error())
|
||||||
ReleaseRpcRequest(req)
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ReleaseRpcRequest(req)
|
||||||
v := client.RemovePending(callSeq)
|
v := client.RemovePending(callSeq)
|
||||||
if v == nil {
|
if v == nil {
|
||||||
log.SError("rpcClient cannot find seq ",callSeq, " in pending")
|
log.SError("rpcClient cannot find seq ",callSeq, " in pending")
|
||||||
ReleaseRpcRequest(req)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if len(Err) == 0 {
|
if len(Err) == 0 {
|
||||||
@@ -326,7 +326,6 @@ func (server *Server) selfNodeRpcHandlerGo(processor IRpcProcessor, client *Clie
|
|||||||
v.Err = Err
|
v.Err = Err
|
||||||
}
|
}
|
||||||
v.done <- v
|
v.done <- v
|
||||||
ReleaseRpcRequest(req)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user