X-Git-Url: https://gerrit.fd.io/r/gitweb?p=govpp.git;a=blobdiff_plain;f=core%2Fconnection.go;fp=core%2Fconnection.go;h=f796f3daa55fb5487e9094736e88527357f207ef;hp=1bfcae5bb03a951fd95e9dd6408246fd85554da3;hb=945b7c7ae69c414ef851f85596be4edeb1d9290e;hpb=4a4094e6cdc7f5d9e5a470ccf82df1c780c7e224 diff --git a/core/connection.go b/core/connection.go index 1bfcae5..f796f3d 100644 --- a/core/connection.go +++ b/core/connection.go @@ -216,14 +216,18 @@ func (c *Connection) Disconnect() { return } if c.vppClient != nil { - c.disconnectVPP() + c.disconnectVPP(true) } } -// disconnectVPP disconnects from VPP in case it is connected. -func (c *Connection) disconnectVPP() { +// disconnectVPP disconnects from VPP in case it is connected. terminate tells +// that disconnectVPP() was called from Close(), so healthCheckLoop() can be +// terminated. +func (c *Connection) disconnectVPP(terminate bool) { if atomic.CompareAndSwapUint32(&c.vppConnected, 1, 0) { - close(c.healthCheckDone) + if terminate { + close(c.healthCheckDone) + } log.Debug("Disconnecting from VPP..") if err := c.vppClient.Disconnect(); err != nil { @@ -383,7 +387,7 @@ HealthCheck: } // cleanup - c.disconnectVPP() + c.disconnectVPP(false) // we are now disconnected, start connect loop c.connectLoop()