mirror of
https://github.com/duanhf2012/origin.git
synced 2026-05-21 09:07:30 +08:00
修正调用本地rpc出错时,管道连接会产生断开,无法自动重连
This commit is contained in:
@@ -101,13 +101,15 @@ func (slf *CCluster) ListenService() error {
|
|||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
return err2
|
return err2
|
||||||
}
|
}
|
||||||
|
go slf.AcceptRpc(tcplisten)
|
||||||
|
slf.ReSetLocalRpcClient()
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (slf *CCluster) ReSetLocalRpcClient() {
|
||||||
slf.reader, slf.writer = net.Pipe()
|
slf.reader, slf.writer = net.Pipe()
|
||||||
go rpc.ServeConn(slf.reader)
|
go rpc.ServeConn(slf.reader)
|
||||||
slf.LocalRpcClient = rpc.NewClient(slf.writer)
|
slf.LocalRpcClient = rpc.NewClient(slf.writer)
|
||||||
|
|
||||||
go slf.AcceptRpc(tcplisten)
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type CPing struct {
|
type CPing struct {
|
||||||
@@ -172,6 +174,9 @@ func (slf *CCluster) ConnService() error {
|
|||||||
v.pclient = client
|
v.pclient = client
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if slf.LocalRpcClient.IsClosed() {
|
||||||
|
slf.ReSetLocalRpcClient()
|
||||||
|
}
|
||||||
time.Sleep(time.Second * 4)
|
time.Sleep(time.Second * 4)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user