mirror of
https://github.com/duanhf2012/origin.git
synced 2026-02-04 06:54:45 +08:00
优化rpc
This commit is contained in:
@@ -9,6 +9,7 @@ import (
|
|||||||
"sync"
|
"sync"
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
"time"
|
"time"
|
||||||
|
"github.com/duanhf2012/origin/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
const(
|
const(
|
||||||
@@ -87,7 +88,8 @@ func (bc *Client) checkRpcCallTimeout() {
|
|||||||
pCall := pElem.Value.(*Call)
|
pCall := pElem.Value.(*Call)
|
||||||
if now.Sub(pCall.callTime) > bc.callRpcTimeout {
|
if now.Sub(pCall.callTime) > bc.callRpcTimeout {
|
||||||
strTimeout := strconv.FormatInt(int64(bc.callRpcTimeout/time.Second), 10)
|
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.makeCallFail(pCall)
|
||||||
bc.pendingLock.Unlock()
|
bc.pendingLock.Unlock()
|
||||||
continue
|
continue
|
||||||
|
|||||||
@@ -375,21 +375,21 @@ func (server *Server) selfNodeRpcHandlerAsyncGo(client *Client, callerRpcHandler
|
|||||||
req.requestHandle = func(Returns interface{}, Err RpcError) {
|
req.requestHandle = func(Returns interface{}, Err RpcError) {
|
||||||
v := client.RemovePending(callSeq)
|
v := client.RemovePending(callSeq)
|
||||||
if v == nil {
|
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)
|
//ReleaseCall(pCall)
|
||||||
ReleaseRpcRequest(req)
|
ReleaseRpcRequest(req)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if len(Err) == 0 {
|
if len(Err) == 0 {
|
||||||
pCall.Err = nil
|
v.Err = nil
|
||||||
} else {
|
} else {
|
||||||
pCall.Err = Err
|
v.Err = Err
|
||||||
}
|
}
|
||||||
|
|
||||||
if Returns != nil {
|
if Returns != nil {
|
||||||
pCall.Reply = Returns
|
v.Reply = Returns
|
||||||
}
|
}
|
||||||
pCall.rpcHandler.PushRpcResponse(pCall)
|
v.rpcHandler.PushRpcResponse(v)
|
||||||
ReleaseRpcRequest(req)
|
ReleaseRpcRequest(req)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user