diff options
| author | jwijenbergh <jeroenwijenbergh@protonmail.com> | 2022-10-25 11:44:04 +0200 |
|---|---|---|
| committer | jwijenbergh <jeroenwijenbergh@protonmail.com> | 2022-10-25 11:44:04 +0200 |
| commit | b4be281671ecfe5c1e6f831614ca1dde48522cd7 (patch) | |
| tree | 60607908ae545d32aabc08d86d22444003744d65 /client/server.go | |
| parent | c9603e4a2ec682ca30399205ccbf533f55230ad4 (diff) | |
Client + FSM: Remove background argument from transition
This fixes a race condition reported by Go's -race flag
In the future we should use waitgroups to ensure the OAuth local listener is started before we sent the URL
Diffstat (limited to 'client/server.go')
| -rw-r--r-- | client/server.go | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/client/server.go b/client/server.go index 2274378..ee6ec11 100644 --- a/client/server.go +++ b/client/server.go @@ -90,7 +90,7 @@ func (client *Client) getConfig( } // Signal the server display info - client.FSM.GoTransitionWithData(STATE_DISCONNECTED, currentServer, false) + client.FSM.GoTransitionWithData(STATE_DISCONNECTED, currentServer) // Save the config saveErr := client.Config.Save(&client) @@ -142,7 +142,7 @@ func (client *Client) RemoveSecureInternet() error { } // No error because we can only have one secure internet server and if there are no secure internet servers, this is a NO-OP client.Servers.RemoveSecureInternet() - client.FSM.GoTransitionWithData(STATE_NO_SERVER, client.Servers, false) + client.FSM.GoTransitionWithData(STATE_NO_SERVER, client.Servers) // Save the config saveErr := client.Config.Save(&client) if saveErr != nil { @@ -168,7 +168,7 @@ func (client *Client) RemoveInstituteAccess(url string) error { } // No error because this is a NO-OP if the server doesn't exist client.Servers.RemoveInstituteAccess(url) - client.FSM.GoTransitionWithData(STATE_NO_SERVER, client.Servers, false) + client.FSM.GoTransitionWithData(STATE_NO_SERVER, client.Servers) // Save the config saveErr := client.Config.Save(&client) if saveErr != nil { @@ -194,7 +194,7 @@ func (client *Client) RemoveCustomServer(url string) error { } // No error because this is a NO-OP if the server doesn't exist client.Servers.RemoveCustomServer(url) - client.FSM.GoTransitionWithData(STATE_NO_SERVER, client.Servers, false) + client.FSM.GoTransitionWithData(STATE_NO_SERVER, client.Servers) // Save the config saveErr := client.Config.Save(&client) if saveErr != nil { @@ -253,7 +253,7 @@ func (client *Client) AddInstituteServer(url string) (server.Server, error) { return nil, client.handleError(errorMessage, loginErr) } - client.FSM.GoTransitionWithData(STATE_NO_SERVER, client.Servers, false) + client.FSM.GoTransitionWithData(STATE_NO_SERVER, client.Servers) return server, nil } @@ -312,7 +312,7 @@ func (client *Client) AddSecureInternetHomeServer(orgID string) (server.Server, _ = client.RemoveSecureInternet() return nil, client.handleError(errorMessage, loginErr) } - client.FSM.GoTransitionWithData(STATE_NO_SERVER, client.Servers, false) + client.FSM.GoTransitionWithData(STATE_NO_SERVER, client.Servers) return server, nil } @@ -359,7 +359,7 @@ func (client *Client) AddCustomServer(url string) (server.Server, error) { return nil, client.handleError(errorMessage, loginErr) } - client.FSM.GoTransitionWithData(STATE_NO_SERVER, client.Servers, false) + client.FSM.GoTransitionWithData(STATE_NO_SERVER, client.Servers) return server, nil } @@ -483,7 +483,7 @@ func (client *Client) askSecureLocation() error { locations := client.Discovery.GetSecureLocationList() // Ask for the location in the callback - client.FSM.GoTransitionWithData(STATE_ASK_LOCATION, locations, false) + client.FSM.GoTransitionWithData(STATE_ASK_LOCATION, locations) // The state has changed, meaning setting the secure location was not successful if client.FSM.Current != STATE_ASK_LOCATION { @@ -518,7 +518,7 @@ func (client *Client) ChangeSecureLocation() error { } // Go back to the main screen - client.FSM.GoTransitionWithData(STATE_NO_SERVER, client.Servers, false) + client.FSM.GoTransitionWithData(STATE_NO_SERVER, client.Servers) return nil } @@ -577,7 +577,7 @@ func (client *Client) ensureLogin(chosenServer server.Server) error { if server.NeedsRelogin(chosenServer) { url, urlErr := server.GetOAuthURL(chosenServer, client.Name) - client.FSM.GoTransitionWithData(STATE_OAUTH_STARTED, url, true) + client.FSM.GoTransitionWithData(STATE_OAUTH_STARTED, url) if urlErr != nil { client.goBackInternal() |
