Skip to content

Commit

Permalink
aws/csm: Fix metricChan's unsafe atomic operations (#2785)
Browse files Browse the repository at this point in the history
This ensures correct atomic operations and fixes test errors on 32-bit platforms like 386 and arm.

Fixes #2784
  • Loading branch information
anthonyfok authored and jasdel committed Aug 29, 2019
1 parent d1c74a6 commit b061de5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG_PENDING.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
### SDK Enhancements

### SDK Bugs
* `aws/csm`: Fix metricChan's unsafe atomic operations ([#2785](https://github.com/aws/aws-sdk-go/pull/2785))
* Fixes [#2784](https://github.com/aws/aws-sdk-go/issues/2784) test failure caused by the metricChan.paused member being a value instead of a pointer. If the metricChan value was ever copied the atomic operations performed on paused would be invalid.
* `aws/client`: Updates logic for calculating the delay after which a request can be retried. Retry delay now includes the Retry-After duration specified in a request [#2796](https://github.com/aws/aws-sdk-go/pull/2796).
* Fixes broken test for retry delays for throttled exceptions. Fixes [#2795](https://github.com/aws/aws-sdk-go/issues/2795)

11 changes: 6 additions & 5 deletions aws/csm/metric_chan.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,26 @@ var (

type metricChan struct {
ch chan metric
paused int64
paused *int64
}

func newMetricChan(size int) metricChan {
return metricChan{
ch: make(chan metric, size),
ch: make(chan metric, size),
paused: new(int64),
}
}

func (ch *metricChan) Pause() {
atomic.StoreInt64(&ch.paused, pausedEnum)
atomic.StoreInt64(ch.paused, pausedEnum)
}

func (ch *metricChan) Continue() {
atomic.StoreInt64(&ch.paused, runningEnum)
atomic.StoreInt64(ch.paused, runningEnum)
}

func (ch *metricChan) IsPaused() bool {
v := atomic.LoadInt64(&ch.paused)
v := atomic.LoadInt64(ch.paused)
return v == pausedEnum
}

Expand Down

0 comments on commit b061de5

Please sign in to comment.