Skip to content
This repository has been archived by the owner on Dec 16, 2022. It is now read-only.

Commit

Permalink
Merge pull request vitessio#4729 from techninja1008/master
Browse files Browse the repository at this point in the history
Fix go panic caused by unaligned atomic fields on certain architectures.
  • Loading branch information
sougou authored Mar 19, 2019
2 parents 20bd2bb + e32cc4d commit 5d425ed
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions go/pools/resource_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,19 +48,20 @@ type Resource interface {

// ResourcePool allows you to use a pool of resources.
type ResourcePool struct {
resources chan resourceWrapper
factory Factory
capacity sync2.AtomicInt64
idleTimeout sync2.AtomicDuration
idleTimer *timer.Timer

// stats
// stats. Atomic fields must remain at the top in order to prevent panics on certain architectures.
available sync2.AtomicInt64
active sync2.AtomicInt64
inUse sync2.AtomicInt64
waitCount sync2.AtomicInt64
waitTime sync2.AtomicDuration
idleClosed sync2.AtomicInt64

capacity sync2.AtomicInt64
idleTimeout sync2.AtomicDuration

resources chan resourceWrapper
factory Factory
idleTimer *timer.Timer
}

type resourceWrapper struct {
Expand Down

0 comments on commit 5d425ed

Please sign in to comment.