Drain the desc channel after registering
This avoids leaking goroutines. Signed-off-by: beorn7 <beorn@soundcloud.com>
This commit is contained in:
parent
2d5a6493f8
commit
7eb5e8a08a
|
@ -273,7 +273,12 @@ func (r *Registry) Register(c Collector) error {
|
|||
close(descChan)
|
||||
}()
|
||||
r.mtx.Lock()
|
||||
defer r.mtx.Unlock()
|
||||
defer func() {
|
||||
// Drain channel in case of premature return to not leak a goroutine.
|
||||
for range descChan {
|
||||
}
|
||||
r.mtx.Unlock()
|
||||
}()
|
||||
// Conduct various tests...
|
||||
for desc := range descChan {
|
||||
|
||||
|
|
Loading…
Reference in New Issue