Merge pull request #2090 from nathanleclaire/heartbeat_disconnect

Stop heartbeat when there is an issue connecting to the server
This commit is contained in:
Olivier Gambier 2015-10-27 11:41:40 -07:00
commit 104ebf58cf
1 changed files with 5 additions and 3 deletions

View File

@ -73,19 +73,21 @@ func NewRpcClientDriver(rawDriverData []byte, driverName string) (*RpcClientDriv
heartbeatDoneCh: make(chan bool),
}
go func(heartbeatDoneCh <-chan bool) {
go func(c *RpcClientDriver) {
for {
select {
case <-heartbeatDoneCh:
case <-c.heartbeatDoneCh:
return
default:
if err := c.Client.Call("RpcServerDriver.Heartbeat", struct{}{}, nil); err != nil {
log.Warnf("Error attempting heartbeat call to plugin server: %s", err)
c.Close()
return
}
time.Sleep(heartbeatInterval)
}
}
}(c.heartbeatDoneCh)
}(c)
var version int
if err := c.Client.Call("RpcServerDriver.GetVersion", struct{}{}, &version); err != nil {