mirror of
https://github.com/netbirdio/netbird.git
synced 2026-10-23 22:09:09 +02:00
Fix blocking Close
This commit is contained in:
@@ -3,6 +3,7 @@ package internal
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"os"
|
"os"
|
||||||
|
"sync"
|
||||||
|
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
|
|
||||||
@@ -28,6 +29,7 @@ type ConnMgr struct {
|
|||||||
|
|
||||||
excludes map[string]struct{}
|
excludes map[string]struct{}
|
||||||
|
|
||||||
|
wg sync.WaitGroup
|
||||||
ctxCancel context.CancelFunc
|
ctxCancel context.CancelFunc
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -54,6 +56,7 @@ func (e *ConnMgr) Start(parentCtx context.Context) {
|
|||||||
e.ctxCancel = cancel
|
e.ctxCancel = cancel
|
||||||
|
|
||||||
e.lazyConnMgr.Start(ctx)
|
e.lazyConnMgr.Start(ctx)
|
||||||
|
e.wg.Add(1)
|
||||||
go e.receiveLazyConnEvents(ctx)
|
go e.receiveLazyConnEvents(ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -126,13 +129,13 @@ func (e *ConnMgr) Close() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
e.ctxCancel()
|
e.ctxCancel()
|
||||||
|
|
||||||
// todo wait for receiveLazyConnEvents to finish
|
|
||||||
e.lazyConnMgr.Close()
|
e.lazyConnMgr.Close()
|
||||||
|
e.wg.Wait()
|
||||||
e.lazyConnMgr = nil
|
e.lazyConnMgr = nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *ConnMgr) receiveLazyConnEvents(ctx context.Context) {
|
func (e *ConnMgr) receiveLazyConnEvents(ctx context.Context) {
|
||||||
|
defer e.wg.Done()
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case <-ctx.Done():
|
case <-ctx.Done():
|
||||||
|
|||||||
Reference in New Issue
Block a user