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