mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
Replace unnecessary Lock()/Unlock()s with RLock()/RUnlock()s Signed-off-by: caojiamingalan <alan.c.19971111@gmail.com>
This commit is contained in:
@@ -74,8 +74,8 @@ func (s *alarmBackend) mustUnsafeDeleteAlarm(tx backend.BatchTx, alarm *etcdserv
|
||||
|
||||
func (s *alarmBackend) GetAllAlarms() ([]*etcdserverpb.AlarmMember, error) {
|
||||
tx := s.be.ReadTx()
|
||||
tx.Lock()
|
||||
defer tx.Unlock()
|
||||
tx.RLock()
|
||||
defer tx.RUnlock()
|
||||
return s.unsafeGetAllAlarms(tx)
|
||||
}
|
||||
|
||||
|
||||
@@ -207,8 +207,8 @@ func (s *membershipBackend) ClusterVersionFromBackend() *semver.Version {
|
||||
func (s *membershipBackend) DowngradeInfoFromBackend() *version.DowngradeInfo {
|
||||
dkey := ClusterDowngradeKeyName
|
||||
tx := s.be.ReadTx()
|
||||
tx.Lock()
|
||||
defer tx.Unlock()
|
||||
tx.RLock()
|
||||
defer tx.RUnlock()
|
||||
keys, vals := tx.UnsafeRange(Cluster, dkey, nil, 0)
|
||||
if len(keys) == 0 {
|
||||
return nil
|
||||
|
||||
@@ -27,8 +27,8 @@ import (
|
||||
|
||||
// Validate checks provided backend to confirm that schema used is supported.
|
||||
func Validate(lg *zap.Logger, tx backend.ReadTx) error {
|
||||
tx.Lock()
|
||||
defer tx.Unlock()
|
||||
tx.RLock()
|
||||
defer tx.RUnlock()
|
||||
return unsafeValidate(lg, tx)
|
||||
}
|
||||
|
||||
|
||||
@@ -24,8 +24,8 @@ import (
|
||||
// ReadStorageVersion loads storage version from given backend transaction.
|
||||
// Populated since v3.6
|
||||
func ReadStorageVersion(tx backend.ReadTx) *semver.Version {
|
||||
tx.Lock()
|
||||
defer tx.Unlock()
|
||||
tx.RLock()
|
||||
defer tx.RUnlock()
|
||||
return UnsafeReadStorageVersion(tx)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user