control/controlclient: eliminate race in loginGoal access.

This code is currently racy due to an incorrect assumption
that goal is never modified in-place, so does not require extra locking.
This change makes the assumption correct.

Signed-off-by: Dmytro Shynkevych <dmytro@tailscale.com>
This commit is contained in:
Dmytro Shynkevych 2020-07-15 13:00:20 -04:00
parent 19d77ce6a3
commit d361511512
No known key found for this signature in database
GPG Key ID: FF5E2F3DAD97EA23

View File

@ -355,12 +355,13 @@ func (c *Client) authRoutine() {
err = fmt.Errorf("weird: server required a new url?") err = fmt.Errorf("weird: server required a new url?")
report(err, "WaitLoginURL") report(err, "WaitLoginURL")
} }
goal.url = url
goal.token = nil
goal.flags = LoginDefault
c.mu.Lock() c.mu.Lock()
c.loginGoal = goal c.loginGoal = &LoginGoal{
wantLoggedIn: true,
flags: LoginDefault,
url: url,
}
c.state = StateURLVisitRequired c.state = StateURLVisitRequired
c.synced = false c.synced = false
c.mu.Unlock() c.mu.Unlock()