mirror of
https://github.com/duanhf2012/origin.git
synced 2026-02-04 06:54:45 +08:00
修正调用本地rpc出错时,管道连接会产生断开,无法自动重连
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user