mirror of
https://github.com/zalando/postgres-operator.git
synced 2026-10-02 10:02:40 +02:00
unlock mutex after handling event, now with non-blocking default case
This commit is contained in:
@@ -1034,10 +1034,15 @@ func (c *Cluster) processPodEvent(obj interface{}) error {
|
||||
|
||||
c.podSubscribersMu.RLock()
|
||||
subscriber, ok := c.podSubscribers[spec.NamespacedName(event.PodName)]
|
||||
c.podSubscribersMu.RUnlock()
|
||||
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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user