Skip to content

Commit

Permalink
Fix leaking locked mutex in netmonitor
Browse files Browse the repository at this point in the history
watcher of LinuxNetworkMonitor would leave the mutex in a locked state
in some cases, causing DPC Manager to deadlock.

Signed-off-by: Milan Lenco <milan@zededa.com>
  • Loading branch information
milan-zededa authored and eriknordmark committed Apr 21, 2022
1 parent 2734d55 commit 17a7737
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions pkg/pillar/netmonitor/linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,6 @@ func (m *LinuxNetworkMonitor) watcher() {
m.Unlock()

case dnsChange := <-dnsWatcher.Events:
m.Lock()
switch dnsChange.Op {
case fsnotify.Create, fsnotify.Remove, fsnotify.Write:
ifName := devicenetwork.ResolvConfToIfname(dnsChange.Name)
Expand All @@ -513,15 +512,18 @@ func (m *LinuxNetworkMonitor) watcher() {
event := DNSInfoChange{
IfIndex: ifIndex,
}
if dnsChange.Op != fsnotify.Remove {
event.Info = m.parseDNSInfo(dnsChange.Name)
}
m.Lock()
if dnsChange.Op == fsnotify.Remove {
delete(m.ifIndexToDNS, ifIndex)
} else {
event.Info = m.parseDNSInfo(dnsChange.Name)
m.ifIndexToDNS[ifIndex] = event.Info
}
m.publishEvent(event)
m.Unlock()
}
m.Unlock()
}
}
}
Expand Down

0 comments on commit 17a7737

Please sign in to comment.