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 authored and Cuong Manh Le committed 2024-08-08 01:25:49 +07:00
1 parent 62a0ba8731
commit a007394f60
3 files changed
+42 -20

No files matched your search

+4
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()
}