cmd/cli: ensure goroutines that check DNS terminated

So changes to DNS after ctrld stopped won't be reverted by the goroutine
itself. The problem happens rarely on darwin, because networksetup
command won't propagate config to /etc/resolv.conf if there is no
changes between multiple running.
This commit is contained in:
Cuong Manh Le
2024-08-07 22:55:31 +07:00
committed by Cuong Manh Le
parent 62a0ba8731
commit a007394f60
3 changed files with 42 additions and 20 deletions

View File

@@ -1333,6 +1333,10 @@ func run(appCallback *AppCallback, stopCh chan struct{}) {
close(waitCh)
<-stopCh
// Wait goroutines which watches/manipulates DNS settings terminated,
// ensuring that changes to DNS since here won't be reverted.
p.dnsWg.Wait()
for _, f := range p.onStopped {
f()
}