mirror of
https://github.com/tailscale/tailscale.git
synced 2024-11-29 04:55:31 +00:00
stunner: fix data race.
In very low-latency conditions, a STUN request can complete before the startup loop has finished firing off goroutines, leading to a concurrent map mutation.
This commit is contained in:
parent
7fb8d873ac
commit
dbca186a64
@ -184,6 +184,7 @@ type sender struct {
|
|||||||
defer cancel()
|
defer cancel()
|
||||||
need[server] = sender{ctx, cancel}
|
need[server] = sender{ctx, cancel}
|
||||||
}
|
}
|
||||||
|
needMu.Lock()
|
||||||
for server, sender := range need {
|
for server, sender := range need {
|
||||||
wg.Add(1)
|
wg.Add(1)
|
||||||
server, ctx := server, sender.ctx
|
server, ctx := server, sender.ctx
|
||||||
@ -192,6 +193,7 @@ type sender struct {
|
|||||||
s.sendPackets(ctx, server)
|
s.sendPackets(ctx, server)
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
needMu.Unlock()
|
||||||
var err error
|
var err error
|
||||||
select {
|
select {
|
||||||
case <-ctx.Done():
|
case <-ctx.Done():
|
||||||
|
Loading…
Reference in New Issue
Block a user