mirror of
https://github.com/tailscale/tailscale.git
synced 2025-12-08 02:41:49 +01:00
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
This commit is contained in:
parent
9ac8105fda
commit
3c19addc21
@ -82,7 +82,7 @@ type CompactableChonk interface {
|
|||||||
//
|
//
|
||||||
// Mem implements the Chonk interface.
|
// Mem implements the Chonk interface.
|
||||||
type Mem struct {
|
type Mem struct {
|
||||||
l sync.RWMutex
|
mu sync.RWMutex
|
||||||
aums map[AUMHash]AUM
|
aums map[AUMHash]AUM
|
||||||
parentIndex map[AUMHash][]AUMHash
|
parentIndex map[AUMHash][]AUMHash
|
||||||
|
|
||||||
@ -90,23 +90,23 @@ type Mem struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *Mem) SetLastActiveAncestor(hash AUMHash) error {
|
func (c *Mem) SetLastActiveAncestor(hash AUMHash) error {
|
||||||
c.l.Lock()
|
c.mu.Lock()
|
||||||
defer c.l.Unlock()
|
defer c.mu.Unlock()
|
||||||
c.lastActiveAncestor = &hash
|
c.lastActiveAncestor = &hash
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Mem) LastActiveAncestor() (*AUMHash, error) {
|
func (c *Mem) LastActiveAncestor() (*AUMHash, error) {
|
||||||
c.l.RLock()
|
c.mu.RLock()
|
||||||
defer c.l.RUnlock()
|
defer c.mu.RUnlock()
|
||||||
return c.lastActiveAncestor, nil
|
return c.lastActiveAncestor, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Heads returns AUMs for which there are no children. In other
|
// Heads returns AUMs for which there are no children. In other
|
||||||
// words, the latest AUM in all chains (the 'leaf').
|
// words, the latest AUM in all chains (the 'leaf').
|
||||||
func (c *Mem) Heads() ([]AUM, error) {
|
func (c *Mem) Heads() ([]AUM, error) {
|
||||||
c.l.RLock()
|
c.mu.RLock()
|
||||||
defer c.l.RUnlock()
|
defer c.mu.RUnlock()
|
||||||
out := make([]AUM, 0, 6)
|
out := make([]AUM, 0, 6)
|
||||||
|
|
||||||
// An AUM is a 'head' if there are no nodes for which it is the parent.
|
// 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) {
|
|||||||
|
|
||||||
// AUM returns the AUM with the specified digest.
|
// AUM returns the AUM with the specified digest.
|
||||||
func (c *Mem) AUM(hash AUMHash) (AUM, error) {
|
func (c *Mem) AUM(hash AUMHash) (AUM, error) {
|
||||||
c.l.RLock()
|
c.mu.RLock()
|
||||||
defer c.l.RUnlock()
|
defer c.mu.RUnlock()
|
||||||
aum, ok := c.aums[hash]
|
aum, ok := c.aums[hash]
|
||||||
if !ok {
|
if !ok {
|
||||||
return AUM{}, os.ErrNotExist
|
return AUM{}, os.ErrNotExist
|
||||||
@ -132,8 +132,8 @@ func (c *Mem) AUM(hash AUMHash) (AUM, error) {
|
|||||||
// ChildAUMs returns all AUMs with a specified previous
|
// ChildAUMs returns all AUMs with a specified previous
|
||||||
// AUM hash.
|
// AUM hash.
|
||||||
func (c *Mem) ChildAUMs(prevAUMHash AUMHash) ([]AUM, error) {
|
func (c *Mem) ChildAUMs(prevAUMHash AUMHash) ([]AUM, error) {
|
||||||
c.l.RLock()
|
c.mu.RLock()
|
||||||
defer c.l.RUnlock()
|
defer c.mu.RUnlock()
|
||||||
out := make([]AUM, 0, 6)
|
out := make([]AUM, 0, 6)
|
||||||
for _, entry := range c.parentIndex[prevAUMHash] {
|
for _, entry := range c.parentIndex[prevAUMHash] {
|
||||||
out = append(out, c.aums[entry])
|
out = append(out, c.aums[entry])
|
||||||
@ -147,8 +147,8 @@ func (c *Mem) ChildAUMs(prevAUMHash AUMHash) ([]AUM, error) {
|
|||||||
// as the rest of the TKA implementation assumes that only
|
// as the rest of the TKA implementation assumes that only
|
||||||
// verified AUMs are stored.
|
// verified AUMs are stored.
|
||||||
func (c *Mem) CommitVerifiedAUMs(updates []AUM) error {
|
func (c *Mem) CommitVerifiedAUMs(updates []AUM) error {
|
||||||
c.l.Lock()
|
c.mu.Lock()
|
||||||
defer c.l.Unlock()
|
defer c.mu.Unlock()
|
||||||
if c.aums == nil {
|
if c.aums == nil {
|
||||||
c.parentIndex = make(map[AUMHash][]AUMHash, 64)
|
c.parentIndex = make(map[AUMHash][]AUMHash, 64)
|
||||||
c.aums = make(map[AUMHash]AUM, 64)
|
c.aums = make(map[AUMHash]AUM, 64)
|
||||||
|
|||||||
@ -496,7 +496,7 @@ func (c *compactingChonkFake) PurgeAUMs(hashes []AUMHash) error {
|
|||||||
|
|
||||||
// Avoid go vet complaining about copying a lock value
|
// Avoid go vet complaining about copying a lock value
|
||||||
func cloneMem(src, dst *Mem) {
|
func cloneMem(src, dst *Mem) {
|
||||||
dst.l = sync.RWMutex{}
|
dst.mu = sync.RWMutex{}
|
||||||
dst.aums = src.aums
|
dst.aums = src.aums
|
||||||
dst.parentIndex = src.parentIndex
|
dst.parentIndex = src.parentIndex
|
||||||
dst.lastActiveAncestor = src.lastActiveAncestor
|
dst.lastActiveAncestor = src.lastActiveAncestor
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user