From d3615115129b0f8c930cda7bd31cfa5537bcad10 Mon Sep 17 00:00:00 2001 From: Dmytro Shynkevych Date: Wed, 15 Jul 2020 13:00:20 -0400 Subject: [PATCH] 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 --- control/controlclient/auto.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/control/controlclient/auto.go b/control/controlclient/auto.go index 0d7e247c8..50efeb2e3 100644 --- a/control/controlclient/auto.go +++ b/control/controlclient/auto.go @@ -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()