Skip to content
This repository has been archived by the owner on Nov 20, 2020. It is now read-only.

Commit

Permalink
Fix to remove race conditions.
Browse files Browse the repository at this point in the history
Race conditions arises where, 1 thread is going through vdc.findVAppByName and accesses v.Vdc between line: v.Vdc = &types.Vdc{} and before decodeBody finishes.
  • Loading branch information
aniket-deole committed Nov 12, 2016
1 parent 090ffa5 commit 5f00851
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions vdc.go
Expand Up @@ -60,12 +60,14 @@ func (v *Vdc) Refresh() error {

// Empty struct before a new unmarshal, otherwise we end up with duplicate
// elements in slices.
v.Vdc = &types.Vdc{}
unmarshalledVdc := &types.Vdc{}

if err = decodeBody(resp, v.Vdc); err != nil {
return fmt.Errorf("error decoding Edge Gateway response: %s", err)
if err = decodeBody(resp, unmarshalledVdc); err != nil {
return fmt.Errorf("error decoding vdc response: %s", err)
}

v.Vdc = unmarshalledVdc

// The request was successful
return nil
}
Expand Down

0 comments on commit 5f00851

Please sign in to comment.