Skip to content

Commit

Permalink
defered Unlock only when a lock is set
Browse files Browse the repository at this point in the history
Signed-off-by: Akram Ben Aissi <[email protected]>
  • Loading branch information
akram committed Sep 6, 2023
1 parent 588f582 commit 42a109d
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion controller/cache/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -788,12 +788,12 @@ func (c *liveStateCache) handleModEvent(oldCluster *appv1.Cluster, newCluster *a
func (c *liveStateCache) handleDeleteEvent(clusterServer string) {
c.lock.RLock()
c.clusterSharding.Delete(clusterServer)
defer c.lock.Unlock()
cluster, ok := c.clusters[clusterServer]
c.lock.RUnlock()
if ok {
cluster.Invalidate()
c.lock.Lock()
defer c.lock.Unlock()
delete(c.clusters, clusterServer)
c.lock.Unlock()
}
Expand Down

0 comments on commit 42a109d

Please sign in to comment.