control/controlclient: avert a data race when logging (#8863)

The read of the synced field for logging takes place outside the lock, and
races with other (locked) writes of this field, including for example the one
at current line 556 in mapRoutine.

Updates tailscale/corp#13856

Change-Id: I056b36d7a93025aafdf73528dd7645f10b791af6
Signed-off-by: M. J. Fromberger <fromberger@tailscale.com>
pull/8865/head
M. J. Fromberger 1 year ago committed by GitHub
parent c40d095c35
commit 9e24a6508a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -313,9 +313,12 @@ func (c *Auto) cancelMap() {
// restartMap cancels the existing mapPoll and liteUpdates, and then starts a // restartMap cancels the existing mapPoll and liteUpdates, and then starts a
// new one. // new one.
func (c *Auto) restartMap() { func (c *Auto) restartMap() {
c.cancelMap() c.mu.Lock()
c.cancelMapLocked()
synced := c.synced
c.mu.Unlock()
c.logf("[v1] restartMap: synced=%v", c.synced) c.logf("[v1] restartMap: synced=%v", synced)
select { select {
case c.newMapCh <- struct{}{}: case c.newMapCh <- struct{}{}:

Loading…
Cancel
Save