From 962016d4768b9d38e289d936743c888a532b9900 Mon Sep 17 00:00:00 2001 From: duanhf2012 <6549168@qq.com> Date: Fri, 7 Jul 2023 13:50:57 +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/client.go | 4 +++- rpc/server.go | 10 +++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/rpc/client.go b/rpc/client.go index 8a5d1ce..7f0a5fa 100644 --- a/rpc/client.go +++ b/rpc/client.go @@ -9,6 +9,7 @@ import ( "sync" "sync/atomic" "time" + "github.com/duanhf2012/origin/log" ) const( @@ -87,7 +88,8 @@ func (bc *Client) checkRpcCallTimeout() { pCall := pElem.Value.(*Call) if now.Sub(pCall.callTime) > bc.callRpcTimeout { strTimeout := strconv.FormatInt(int64(bc.callRpcTimeout/time.Second), 10) - pCall.Err = errors.New("RPC call takes more than " + strTimeout + " seconds") + pCall.Err = errors.New("RPC call takes more than " + strTimeout + " seconds,method is "+pCall.ServiceMethod) + log.SError(pCall.Err.Error()) bc.makeCallFail(pCall) bc.pendingLock.Unlock() continue diff --git a/rpc/server.go b/rpc/server.go index 9b67803..7da1844 100644 --- a/rpc/server.go +++ b/rpc/server.go @@ -375,21 +375,21 @@ func (server *Server) selfNodeRpcHandlerAsyncGo(client *Client, callerRpcHandler req.requestHandle = func(Returns interface{}, Err RpcError) { v := client.RemovePending(callSeq) if v == nil { - log.SError("rpcClient cannot find seq ", pCall.Seq, " in pending") + log.SError("rpcClient cannot find seq ", callSeq, " in pending, service method is ",serviceMethod) //ReleaseCall(pCall) ReleaseRpcRequest(req) return } if len(Err) == 0 { - pCall.Err = nil + v.Err = nil } else { - pCall.Err = Err + v.Err = Err } if Returns != nil { - pCall.Reply = Returns + v.Reply = Returns } - pCall.rpcHandler.PushRpcResponse(pCall) + v.rpcHandler.PushRpcResponse(v) ReleaseRpcRequest(req) } }