Skip to content

Commit 43ab8b4

Browse files
alexwlchannickkhyl
authored andcommitted
tka: rename a mutex to mu instead of single-letter l
See http://go/no-ell Updates tailscale/corp#33846 Signed-off-by: Alex Chan <alexc@tailscale.com> Change-Id: I88ecd9db847e04237c1feab9dfcede5ca1050cc5 (cherry picked from commit fca66fb)
1 parent 6b64718 commit 43ab8b4

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

tka/tailchonk.go

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -82,31 +82,31 @@ type CompactableChonk interface {
8282
//
8383
// Mem implements the Chonk interface.
8484
type Mem struct {
85-
l sync.RWMutex
85+
mu sync.RWMutex
8686
aums map[AUMHash]AUM
8787
parentIndex map[AUMHash][]AUMHash
8888

8989
lastActiveAncestor *AUMHash
9090
}
9191

9292
func (c *Mem) SetLastActiveAncestor(hash AUMHash) error {
93-
c.l.Lock()
94-
defer c.l.Unlock()
93+
c.mu.Lock()
94+
defer c.mu.Unlock()
9595
c.lastActiveAncestor = &hash
9696
return nil
9797
}
9898

9999
func (c *Mem) LastActiveAncestor() (*AUMHash, error) {
100-
c.l.RLock()
101-
defer c.l.RUnlock()
100+
c.mu.RLock()
101+
defer c.mu.RUnlock()
102102
return c.lastActiveAncestor, nil
103103
}
104104

105105
// Heads returns AUMs for which there are no children. In other
106106
// words, the latest AUM in all chains (the 'leaf').
107107
func (c *Mem) Heads() ([]AUM, error) {
108-
c.l.RLock()
109-
defer c.l.RUnlock()
108+
c.mu.RLock()
109+
defer c.mu.RUnlock()
110110
out := make([]AUM, 0, 6)
111111

112112
// An AUM is a 'head' if there are no nodes for which it is the parent.
@@ -120,8 +120,8 @@ func (c *Mem) Heads() ([]AUM, error) {
120120

121121
// AUM returns the AUM with the specified digest.
122122
func (c *Mem) AUM(hash AUMHash) (AUM, error) {
123-
c.l.RLock()
124-
defer c.l.RUnlock()
123+
c.mu.RLock()
124+
defer c.mu.RUnlock()
125125
aum, ok := c.aums[hash]
126126
if !ok {
127127
return AUM{}, os.ErrNotExist
@@ -132,8 +132,8 @@ func (c *Mem) AUM(hash AUMHash) (AUM, error) {
132132
// ChildAUMs returns all AUMs with a specified previous
133133
// AUM hash.
134134
func (c *Mem) ChildAUMs(prevAUMHash AUMHash) ([]AUM, error) {
135-
c.l.RLock()
136-
defer c.l.RUnlock()
135+
c.mu.RLock()
136+
defer c.mu.RUnlock()
137137
out := make([]AUM, 0, 6)
138138
for _, entry := range c.parentIndex[prevAUMHash] {
139139
out = append(out, c.aums[entry])
@@ -147,8 +147,8 @@ func (c *Mem) ChildAUMs(prevAUMHash AUMHash) ([]AUM, error) {
147147
// as the rest of the TKA implementation assumes that only
148148
// verified AUMs are stored.
149149
func (c *Mem) CommitVerifiedAUMs(updates []AUM) error {
150-
c.l.Lock()
151-
defer c.l.Unlock()
150+
c.mu.Lock()
151+
defer c.mu.Unlock()
152152
if c.aums == nil {
153153
c.parentIndex = make(map[AUMHash][]AUMHash, 64)
154154
c.aums = make(map[AUMHash]AUM, 64)

tka/tailchonk_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -496,7 +496,7 @@ func (c *compactingChonkFake) PurgeAUMs(hashes []AUMHash) error {
496496

497497
// Avoid go vet complaining about copying a lock value
498498
func cloneMem(src, dst *Mem) {
499-
dst.l = sync.RWMutex{}
499+
dst.mu = sync.RWMutex{}
500500
dst.aums = src.aums
501501
dst.parentIndex = src.parentIndex
502502
dst.lastActiveAncestor = src.lastActiveAncestor

0 commit comments

Comments
 (0)