mirror of
https://github.com/netbirdio/netbird.git
synced 2025-08-19 19:26:52 +02:00
Fix double close in logger
This commit is contained in:
@@ -48,6 +48,7 @@ type Logger struct {
|
||||
level atomic.Uint32
|
||||
buffer *ringBuffer
|
||||
shutdown chan struct{}
|
||||
closeOnce sync.Once
|
||||
wg sync.WaitGroup
|
||||
|
||||
// Reusable buffer pool for formatting messages
|
||||
@@ -170,9 +171,12 @@ func (l *Logger) worker() {
|
||||
|
||||
// Stop gracefully shuts down the logger
|
||||
func (l *Logger) Stop(ctx context.Context) error {
|
||||
close(l.shutdown)
|
||||
|
||||
done := make(chan struct{})
|
||||
|
||||
l.closeOnce.Do(func() {
|
||||
close(l.shutdown)
|
||||
})
|
||||
|
||||
go func() {
|
||||
l.wg.Wait()
|
||||
close(done)
|
||||
|
||||
Reference in New Issue
Block a user