mirror of
https://github.com/strukturag/nextcloud-spreed-signaling
synced 2024-05-30 12:34:13 +02:00
Remove unnecessary state variable.
This commit is contained in:
parent
29b0b06f6d
commit
45be0ad2fd
|
@ -43,8 +43,7 @@ const (
|
|||
type DnsMonitorCallback = func(entry *DnsMonitorEntry, all []net.IP, add []net.IP, keep []net.IP, remove []net.IP)
|
||||
|
||||
type DnsMonitorEntry struct {
|
||||
removing atomic.Bool
|
||||
entry *dnsMonitorEntry
|
||||
entry atomic.Pointer[dnsMonitorEntry]
|
||||
url string
|
||||
callback DnsMonitorCallback
|
||||
}
|
||||
|
@ -222,14 +221,15 @@ func (m *DnsMonitor) Add(target string, callback DnsMonitorCallback) (*DnsMonito
|
|||
}
|
||||
m.hostnames[hostname] = entry
|
||||
}
|
||||
e.entry = entry
|
||||
e.entry.Store(entry)
|
||||
entry.addEntry(e)
|
||||
m.cond.Signal()
|
||||
return e, nil
|
||||
}
|
||||
|
||||
func (m *DnsMonitor) Remove(entry *DnsMonitorEntry) {
|
||||
if !entry.removing.CompareAndSwap(false, true) {
|
||||
oldEntry := entry.entry.Swap(nil)
|
||||
if oldEntry == nil {
|
||||
// Already removed.
|
||||
return
|
||||
}
|
||||
|
@ -247,16 +247,11 @@ func (m *DnsMonitor) Remove(entry *DnsMonitorEntry) {
|
|||
}
|
||||
defer m.mu.Unlock()
|
||||
|
||||
if entry.entry == nil {
|
||||
return
|
||||
}
|
||||
|
||||
e, found := m.hostnames[entry.entry.hostname]
|
||||
e, found := m.hostnames[oldEntry.hostname]
|
||||
if !found {
|
||||
return
|
||||
}
|
||||
|
||||
entry.entry = nil
|
||||
if e.removeEntry(entry) {
|
||||
delete(m.hostnames, e.hostname)
|
||||
}
|
||||
|
@ -273,7 +268,7 @@ func (m *DnsMonitor) clearRemoved() {
|
|||
for hostname, entry := range m.hostnames {
|
||||
deleted := false
|
||||
for e := range entry.entries {
|
||||
if e.removing.Load() {
|
||||
if e.entry.Load() == nil {
|
||||
delete(entry.entries, e)
|
||||
deleted = true
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue