diff options
| author | jwijenbergh <jeroenwijenbergh@protonmail.com> | 2024-07-16 17:17:40 +0200 |
|---|---|---|
| committer | Jeroen Wijenbergh <46386452+jwijenbergh@users.noreply.github.com> | 2024-07-17 14:00:03 +0000 |
| commit | 5362dd10bf13f8087a13a4ab5441efa04755fcc7 (patch) | |
| tree | 66dfc498f786fb3ab52bd4969c76f1e429e13e89 | |
| parent | 47ec3b772ad65c51104b5e9d9b00156d157d751f (diff) | |
Client: Release before calling transitions
| -rw-r--r-- | client/client.go | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/client/client.go b/client/client.go index f437b19..743c79a 100644 --- a/client/client.go +++ b/client/client.go @@ -344,16 +344,16 @@ func (c *Client) AddServer(ck *cookie.Cookie, identifier string, _type srvtypes. var release func() defer func() { - // If we must run callbacks, go to the previous state if we're not in it - if !ni && !c.FSM.InState(previousState) { - c.FSM.GoTransition(previousState) //nolint:errcheck - } if err == nil { c.TrySave() } if release != nil { release() } + // If we must run callbacks, go to the previous state if we're not in it + if !ni && !c.FSM.InState(previousState) { + c.FSM.GoTransition(previousState) //nolint:errcheck + } }() if !ni { @@ -420,6 +420,10 @@ func (c *Client) GetConfig(ck *cookie.Cookie, identifier string, _type srvtypes. var release func() defer func() { + c.TrySave() + if release != nil { + release() + } if err == nil { // it could be that we are not in getting config yet if we have just done authorization c.FSM.GoTransition(StateGettingConfig) //nolint:errcheck @@ -428,10 +432,6 @@ func (c *Client) GetConfig(ck *cookie.Cookie, identifier string, _type srvtypes. // go back to the previous state if an error occurred c.FSM.GoTransition(previousState) //nolint:errcheck } - c.TrySave() - if release != nil { - release() - } }() identifier, err = c.convertIdentifier(identifier, _type) |
