Skip to content

Commit

Permalink
Atomically load from accessState to avoid data race. (ossf#2732)
Browse files Browse the repository at this point in the history
Signed-off-by: Spencer Schrock <sschrock@google.com>
Signed-off-by: Shofiya2003 <shofiyabootwala@gmail.com>
  • Loading branch information
spencerschrock authored and Shofiya2003 committed Mar 10, 2023
1 parent 4c395ae commit ff2f6a7
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 ff2f6a7

Please sign in to comment.