mirror of
https://github.com/fosrl/newt.git
synced 2026-03-27 04:56:41 +00:00
Clean up to match olm
This commit is contained in:
@@ -661,15 +661,7 @@ func (c *Client) setupPKCS12TLS() (*tls.Config, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// pingMonitor sends pings at a short interval and triggers reconnect on failure
|
// pingMonitor sends pings at a short interval and triggers reconnect on failure
|
||||||
func (c *Client) pingMonitor() {
|
func (c *Client) sendPing() {
|
||||||
ticker := time.NewTicker(c.pingInterval)
|
|
||||||
defer ticker.Stop()
|
|
||||||
|
|
||||||
for {
|
|
||||||
select {
|
|
||||||
case <-c.done:
|
|
||||||
return
|
|
||||||
case <-ticker.C:
|
|
||||||
if c.conn == nil {
|
if c.conn == nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -680,7 +672,7 @@ func (c *Client) pingMonitor() {
|
|||||||
c.processingMux.RUnlock()
|
c.processingMux.RUnlock()
|
||||||
if isProcessing {
|
if isProcessing {
|
||||||
logger.Debug("Skipping ping, message is being processed")
|
logger.Debug("Skipping ping, message is being processed")
|
||||||
continue
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
c.configVersionMux.RLock()
|
c.configVersionMux.RLock()
|
||||||
@@ -715,6 +707,21 @@ func (c *Client) pingMonitor() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *Client) pingMonitor() {
|
||||||
|
// Send an immediate ping as soon as we connect
|
||||||
|
c.sendPing()
|
||||||
|
|
||||||
|
ticker := time.NewTicker(c.pingInterval)
|
||||||
|
defer ticker.Stop()
|
||||||
|
|
||||||
|
for {
|
||||||
|
select {
|
||||||
|
case <-c.done:
|
||||||
|
return
|
||||||
|
case <-ticker.C:
|
||||||
|
c.sendPing()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user