From 02b9c8b28bacbfcdce4295dc111479008afe5473 Mon Sep 17 00:00:00 2001 From: boyce Date: Thu, 28 Feb 2019 14:07:09 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A6=82=E6=9E=9Cid=E4=B8=BA=E6=9C=AC=E5=9C=B0?= =?UTF-8?q?node,=E7=9B=B4=E6=8E=A5=E8=BF=94=E5=9B=9Elocalrpcclient?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cluster/cluster.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/cluster/cluster.go b/cluster/cluster.go index 2192d8e..4ab3526 100644 --- a/cluster/cluster.go +++ b/cluster/cluster.go @@ -45,6 +45,10 @@ func (slf *CCluster) ReadNodeInfo(nodeid int) error { } func (slf *CCluster) GetClusterClient(id int) *rpc.Client { + if id == GetNodeId() { + return slf.LocalRpcClient + } + v, ok := slf.nodeclient[id] if ok == false { return nil @@ -130,12 +134,14 @@ func (slf *CCluster) ConnService() error { if rpcClient.isConnect == true { ping.TimeStamp = 0 err := rpcClient.pclient.Call("CPing.Ping", &ping, &pong) + if err != nil { rpcClient.pclient.Close() rpcClient.pclient = nil rpcClient.isConnect = false continue } + continue }