mirror of
https://github.com/tailscale/tailscale.git
synced 2025-04-21 06:01:42 +00:00
ipn: always guard LocalBackend.endpoints with mu
For #112 Signed-off-by: David Crawshaw <crawshaw@tailscale.com>
This commit is contained in:
parent
3425d8d84f
commit
cdc10b74f1
12
ipn/local.go
12
ipn/local.go
@ -48,7 +48,7 @@ type LocalBackend struct {
|
|||||||
hiCache *tailcfg.Hostinfo
|
hiCache *tailcfg.Hostinfo
|
||||||
netMapCache *controlclient.NetworkMap
|
netMapCache *controlclient.NetworkMap
|
||||||
engineStatus EngineStatus
|
engineStatus EngineStatus
|
||||||
endPoints []string // TODO: many uses without holding mu
|
endpoints []string
|
||||||
blocked bool
|
blocked bool
|
||||||
authURL string
|
authURL string
|
||||||
interact int
|
interact int
|
||||||
@ -191,10 +191,11 @@ func (b *LocalBackend) Start(opts Options) error {
|
|||||||
|
|
||||||
b.mu.Lock()
|
b.mu.Lock()
|
||||||
b.c = cli
|
b.c = cli
|
||||||
|
endpoints := b.endpoints
|
||||||
b.mu.Unlock()
|
b.mu.Unlock()
|
||||||
|
|
||||||
if b.endPoints != nil {
|
if endpoints != nil {
|
||||||
cli.UpdateEndpoints(0, b.endPoints)
|
cli.UpdateEndpoints(0, endpoints)
|
||||||
}
|
}
|
||||||
|
|
||||||
cli.SetStatusFunc(func(newSt controlclient.Status) {
|
cli.SetStatusFunc(func(newSt controlclient.Status) {
|
||||||
@ -262,16 +263,17 @@ func (b *LocalBackend) Start(opts Options) error {
|
|||||||
log.Fatalf("weird: non-error wgengine update with status=nil\n")
|
log.Fatalf("weird: non-error wgengine update with status=nil\n")
|
||||||
}
|
}
|
||||||
|
|
||||||
b.mu.Lock() // why does this hold b.mu? parseWgStatus only reads b.logf
|
|
||||||
es := b.parseWgStatus(s)
|
es := b.parseWgStatus(s)
|
||||||
|
|
||||||
|
b.mu.Lock()
|
||||||
c := b.c
|
c := b.c
|
||||||
b.engineStatus = es
|
b.engineStatus = es
|
||||||
|
b.endpoints = append([]string{}, s.LocalAddrs...)
|
||||||
b.mu.Unlock()
|
b.mu.Unlock()
|
||||||
|
|
||||||
if c != nil {
|
if c != nil {
|
||||||
c.UpdateEndpoints(0, s.LocalAddrs)
|
c.UpdateEndpoints(0, s.LocalAddrs)
|
||||||
}
|
}
|
||||||
b.endPoints = append([]string{}, s.LocalAddrs...)
|
|
||||||
b.stateMachine()
|
b.stateMachine()
|
||||||
|
|
||||||
b.statusLock.Lock()
|
b.statusLock.Lock()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user