Switching atomic vars to int32 to address panic on some architectures (#3314)
This commit is contained in:
parent
57a7002210
commit
2002543245
|
@ -60,10 +60,9 @@ type ExpirationManager struct {
|
|||
pending map[string]*time.Timer
|
||||
pendingLock sync.RWMutex
|
||||
|
||||
tidyLock int64
|
||||
tidyLock int32
|
||||
|
||||
// A set of locks to handle restoration
|
||||
restoreMode int64
|
||||
restoreMode int32
|
||||
restoreModeLock sync.RWMutex
|
||||
restoreRequestLock sync.RWMutex
|
||||
restoreLocks []*locksutil.LockEntry
|
||||
|
@ -76,7 +75,6 @@ type ExpirationManager struct {
|
|||
func NewExpirationManager(router *Router, view *BarrierView, ts *TokenStore, logger log.Logger) *ExpirationManager {
|
||||
if logger == nil {
|
||||
logger = log.New("expiration_manager")
|
||||
|
||||
}
|
||||
|
||||
exp := &ExpirationManager{
|
||||
|
@ -150,7 +148,7 @@ func (m *ExpirationManager) unlockLease(leaseID string) {
|
|||
|
||||
// inRestoreMode returns if we are currently in restore mode
|
||||
func (m *ExpirationManager) inRestoreMode() bool {
|
||||
return atomic.LoadInt64(&m.restoreMode) == 1
|
||||
return atomic.LoadInt32(&m.restoreMode) == 1
|
||||
}
|
||||
|
||||
// Tidy cleans up the dangling storage entries for leases. It scans the storage
|
||||
|
@ -166,12 +164,12 @@ func (m *ExpirationManager) Tidy() error {
|
|||
|
||||
var tidyErrors *multierror.Error
|
||||
|
||||
if !atomic.CompareAndSwapInt64(&m.tidyLock, 0, 1) {
|
||||
if !atomic.CompareAndSwapInt32(&m.tidyLock, 0, 1) {
|
||||
m.logger.Warn("expiration: tidy operation on leases is already in progress")
|
||||
return fmt.Errorf("tidy operation on leases is already in progress")
|
||||
}
|
||||
|
||||
defer atomic.CompareAndSwapInt64(&m.tidyLock, 1, 0)
|
||||
defer atomic.CompareAndSwapInt32(&m.tidyLock, 1, 0)
|
||||
|
||||
m.logger.Info("expiration: beginning tidy operation on leases")
|
||||
defer m.logger.Info("expiration: finished tidy operation on leases")
|
||||
|
@ -276,7 +274,7 @@ func (m *ExpirationManager) Restore(errorFunc func(), loadDelay time.Duration) (
|
|||
// if restore mode finished successfully, restore mode was already
|
||||
// disabled with the lock. In an error state, this will allow the
|
||||
// Stop() function to shut everything down.
|
||||
atomic.StoreInt64(&m.restoreMode, 0)
|
||||
atomic.StoreInt32(&m.restoreMode, 0)
|
||||
|
||||
switch {
|
||||
case retErr == nil:
|
||||
|
@ -391,7 +389,7 @@ func (m *ExpirationManager) Restore(errorFunc func(), loadDelay time.Duration) (
|
|||
m.restoreModeLock.Lock()
|
||||
m.restoreLoaded = sync.Map{}
|
||||
m.restoreLocks = nil
|
||||
atomic.StoreInt64(&m.restoreMode, 0)
|
||||
atomic.StoreInt32(&m.restoreMode, 0)
|
||||
m.restoreModeLock.Unlock()
|
||||
|
||||
m.logger.Info("expiration: lease restore complete")
|
||||
|
|
Loading…
Reference in New Issue