mirror of
https://github.com/strukturag/nextcloud-spreed-signaling
synced 2024-05-17 04:56:33 +02:00
"Stop" should wait until stopped in DNS monitor.
This commit is contained in:
parent
2e8b0dfe25
commit
7e613f831b
|
@ -145,6 +145,7 @@ type DnsMonitor struct {
|
||||||
|
|
||||||
stopCtx context.Context
|
stopCtx context.Context
|
||||||
stopFunc func()
|
stopFunc func()
|
||||||
|
stopped chan struct{}
|
||||||
|
|
||||||
mu sync.RWMutex
|
mu sync.RWMutex
|
||||||
cond *sync.Cond
|
cond *sync.Cond
|
||||||
|
@ -167,6 +168,7 @@ func NewDnsMonitor(interval time.Duration) (*DnsMonitor, error) {
|
||||||
|
|
||||||
stopCtx: stopCtx,
|
stopCtx: stopCtx,
|
||||||
stopFunc: stopFunc,
|
stopFunc: stopFunc,
|
||||||
|
stopped: make(chan struct{}),
|
||||||
|
|
||||||
hostnames: make(map[string]*dnsMonitorEntry),
|
hostnames: make(map[string]*dnsMonitorEntry),
|
||||||
}
|
}
|
||||||
|
@ -183,6 +185,7 @@ func (m *DnsMonitor) Start() error {
|
||||||
func (m *DnsMonitor) Stop() {
|
func (m *DnsMonitor) Stop() {
|
||||||
m.stopFunc()
|
m.stopFunc()
|
||||||
m.cond.Signal()
|
m.cond.Signal()
|
||||||
|
<-m.stopped
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *DnsMonitor) Add(target string, callback DnsMonitorCallback) (*DnsMonitorEntry, error) {
|
func (m *DnsMonitor) Add(target string, callback DnsMonitorCallback) (*DnsMonitorEntry, error) {
|
||||||
|
@ -296,6 +299,7 @@ func (m *DnsMonitor) waitForEntries() (waited bool) {
|
||||||
func (m *DnsMonitor) run() {
|
func (m *DnsMonitor) run() {
|
||||||
ticker := time.NewTicker(m.interval)
|
ticker := time.NewTicker(m.interval)
|
||||||
defer ticker.Stop()
|
defer ticker.Stop()
|
||||||
|
defer close(m.stopped)
|
||||||
|
|
||||||
for {
|
for {
|
||||||
if m.waitForEntries() {
|
if m.waitForEntries() {
|
||||||
|
|
Loading…
Reference in a new issue