Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix go panic caused by unaligned atomic fields on certain architectures. #4729

Merged
merged 1 commit into from
Mar 19, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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