Commit 84572285 by ale

Fix semantics of SubscribeUnitsCustom filter

It was accidentally inverted.
1 parent cf4ab1f4
Pipeline #185 passed
in 40 seconds
Showing with 7 additions and 2 deletions
......@@ -289,14 +289,17 @@ func watchSystemd(configCh <-chan map[string]*Service, opCh chan dnsOp) {
}
var mx sync.Mutex
// Note that the semantics of the filter function are the opposite
// of what one would normally expect: it should return true for
// units that should be ignored, false for the ones we care about.
updateCh, errCh := conn.SubscribeUnitsCustom(time.Second, 256, compareUnitStatus, func(unit string) bool {
mx.Lock()
defer mx.Unlock()
if state.services == nil {
return false
return true
}
_, ok := state.services[unit]
return ok
return !ok
})
for {
......@@ -313,6 +316,8 @@ func watchSystemd(configCh <-chan map[string]*Service, opCh chan dnsOp) {
svc, ok := state.services[unit]
mx.Unlock()
if !ok {
// Service map has changed since we last
// invoked the filter function, ignore.
continue
}
unitOk := false
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!