unlock mutex after handling event, now with non-blocking default case
This commit is contained in:
parent
125512eb82
commit
264e66d0a1
|
|
@ -1034,10 +1034,15 @@ func (c *Cluster) processPodEvent(obj interface{}) error {
|
||||||
|
|
||||||
c.podSubscribersMu.RLock()
|
c.podSubscribersMu.RLock()
|
||||||
subscriber, ok := c.podSubscribers[spec.NamespacedName(event.PodName)]
|
subscriber, ok := c.podSubscribers[spec.NamespacedName(event.PodName)]
|
||||||
c.podSubscribersMu.RUnlock()
|
|
||||||
if ok {
|
if ok {
|
||||||
subscriber <- event
|
select {
|
||||||
|
case subscriber <- event:
|
||||||
|
default:
|
||||||
|
// we end up here when there is no receiver of the channel
|
||||||
|
// avoiding a deadlock: https://gobyexample.com/non-blocking-channel-operations
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
c.podSubscribersMu.RUnlock()
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue