修正调用本地rpc出错时,管道连接会产生断开,无法自动重连

This commit is contained in:
boyce
2019-06-03 19:38:44 +08:00
parent 11dd476761
commit 99b026b45e

View File

@@ -101,13 +101,15 @@ func (slf *CCluster) ListenService() error {
os.Exit(1)
return err2
}
go slf.AcceptRpc(tcplisten)
slf.ReSetLocalRpcClient()
return nil
}
func (slf *CCluster) ReSetLocalRpcClient() {
slf.reader, slf.writer = net.Pipe()
go rpc.ServeConn(slf.reader)
slf.LocalRpcClient = rpc.NewClient(slf.writer)
go slf.AcceptRpc(tcplisten)
return nil
}
type CPing struct {
@@ -172,6 +174,9 @@ func (slf *CCluster) ConnService() error {
v.pclient = client
}
if slf.LocalRpcClient.IsClosed() {
slf.ReSetLocalRpcClient()
}
time.Sleep(time.Second * 4)
}