1
0
mirror of https://github.com/etcd-io/etcd.git synced 2026-02-05 15:46:51 +01:00

perf: use RLock in Demoted method for read-only access to expiry

Signed-off-by: huangzw <huangzw@2345.com>
This commit is contained in:
huangzw
2025-02-17 16:03:28 +08:00
parent eb7607bd8b
commit e10f01edfe

View File

@@ -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
}