Skip to content

Commit

Permalink
Atomically load from accessState to avoid data race. (#2732)
Browse files Browse the repository at this point in the history
Signed-off-by: Spencer Schrock <sschrock@google.com>
  • Loading branch information
spencerschrock authored Mar 8, 2023
1 parent 0c090b3 commit 5f13a66
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion clients/githubrepo/roundtripper/tokens/round_robin.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func (tokens *roundRobinAccessor) Next() (uint64, string) {

// If selected accessToken is unavailable, wait.
for !atomic.CompareAndSwapInt64(&tokens.accessState[index], 0, time.Now().Unix()) {
currVal := tokens.accessState[index]
currVal := atomic.LoadInt64(&tokens.accessState[index])
expired := time.Now().After(time.Unix(currVal, 0).Add(expiryTimeInSec * time.Second))
if !expired {
continue
Expand Down

0 comments on commit 5f13a66

Please sign in to comment.