Skip to content

Commit 62e6e0c

Browse files
committed
once
1 parent 5323068 commit 62e6e0c

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

plugins/inputs/prometheus/target_allocator.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"os"
1010
"path/filepath"
1111
"strings"
12+
"sync"
1213
"time"
1314

1415
"github.com/go-kit/log"
@@ -42,6 +43,7 @@ type TargetAllocatorManager struct {
4243
enabled bool
4344
host component.Host
4445
shutdownCh chan struct{}
46+
shutdownOnce sync.Once
4547
taReadyCh chan struct{}
4648
reloadConfigHandler func(config *promconfig.Config)
4749
manager *tamanager.Manager
@@ -177,7 +179,9 @@ func (tam *TargetAllocatorManager) Run() error {
177179
}
178180
func (tam *TargetAllocatorManager) Shutdown() {
179181
tam.manager.Shutdown()
180-
close(tam.shutdownCh)
182+
tam.shutdownOnce.Do(func() {
183+
close(tam.shutdownCh)
184+
})
181185
}
182186
func (tam *TargetAllocatorManager) AttachReloadConfigHandler(handler func(config *promconfig.Config)) {
183187
tam.reloadConfigHandler = handler

0 commit comments

Comments
 (0)