mirror of
https://github.com/status-im/consul.git
synced 2025-01-22 03:29:43 +00:00
add WaitGroup to h2ping
This commit is contained in:
parent
5307c5c3a1
commit
a2e6ca1226
@ -519,6 +519,7 @@ type CheckH2PING struct {
|
|||||||
stop bool
|
stop bool
|
||||||
stopCh chan struct{}
|
stopCh chan struct{}
|
||||||
stopLock sync.Mutex
|
stopLock sync.Mutex
|
||||||
|
stopWg sync.WaitGroup
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *CheckH2PING) check() {
|
func (c *CheckH2PING) check() {
|
||||||
@ -559,9 +560,11 @@ func (c *CheckH2PING) Stop() {
|
|||||||
c.stop = true
|
c.stop = true
|
||||||
close(c.stopCh)
|
close(c.stopCh)
|
||||||
}
|
}
|
||||||
|
c.stopWg.Wait()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *CheckH2PING) run() {
|
func (c *CheckH2PING) run() {
|
||||||
|
defer c.stopWg.Done()
|
||||||
// Get the randomized initial pause time
|
// Get the randomized initial pause time
|
||||||
initialPauseTime := lib.RandomStagger(c.Interval)
|
initialPauseTime := lib.RandomStagger(c.Interval)
|
||||||
next := time.After(initialPauseTime)
|
next := time.After(initialPauseTime)
|
||||||
@ -584,6 +587,7 @@ func (c *CheckH2PING) Start() {
|
|||||||
}
|
}
|
||||||
c.stop = false
|
c.stop = false
|
||||||
c.stopCh = make(chan struct{})
|
c.stopCh = make(chan struct{})
|
||||||
|
c.stopWg.Add(1)
|
||||||
go c.run()
|
go c.run()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user