Skip to content

Commit

Permalink
perf: use RLock in Demoted method for read-only access to expiry
Browse files Browse the repository at this point in the history
  • Loading branch information
huangzw committed Feb 17, 2025
1 parent eb7607b commit 15bf979
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions server/lease/lease.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ func (l *Lease) forever() {

// Demoted returns true if the lease's expiry has been reset to forever.
func (l *Lease) Demoted() bool {
l.expiryMu.Lock()
defer l.expiryMu.Unlock()
l.expiryMu.RLock()
defer l.expiryMu.RUnlock()
return l.expiry == forever
}

Expand Down

0 comments on commit 15bf979

Please sign in to comment.