Skip to content

Commit

Permalink
refactor: lock sendMu only once in waitFn
Browse files Browse the repository at this point in the history
  • Loading branch information
vladklokun committed Jun 12, 2024
1 parent 2b4966c commit 554eeaf
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions internal/services/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ func (c *Controller) Run(ctx context.Context) error {
}
// Since Mutex.TryLock() acquires a lock on success,
// release it immediately to allow the new sending goroutine to do its job.
c.sendMu.Unlock()
defer c.sendMu.Unlock()
c.send(ctx)
}, c.cfg.Interval, ctx.Done())
return nil
Expand Down Expand Up @@ -438,8 +438,6 @@ func (c *Controller) processItem(i interface{}) {
func (c *Controller) send(ctx context.Context) {
c.deltaMu.Lock()
defer c.deltaMu.Unlock()
c.sendMu.Lock()
defer c.sendMu.Unlock()

nodesByName := map[string]*corev1.Node{}
var nodes []*corev1.Node
Expand Down

0 comments on commit 554eeaf

Please sign in to comment.