Skip to content

Commit

Permalink
Merge remote-tracking branch 'oss/master' into okta-lib-baseurl
Browse files Browse the repository at this point in the history
* oss/master:
  fix: add missing comma to payload (#3308)
  Switching atomic vars to int32 to address panic on some architectures (#3314)
  • Loading branch information
Chris Hoffman committed Sep 11, 2017
2 parents e78d769 + 157f2a7 commit fede390
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
16 changes: 7 additions & 9 deletions vault/expiration.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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{
Expand Down Expand Up @@ -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
Expand All @@ -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")
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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")
Expand Down
2 changes: 1 addition & 1 deletion website/source/api/secret/databases/mysql-maria.html.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ has a number of parameters to further configure a connection.
{
"plugin_name": "mysql-database-plugin",
"allowed_roles": "readonly",
"connection_url": "root:mysql@tcp(127.0.0.1:3306)/"
"connection_url": "root:mysql@tcp(127.0.0.1:3306)/",
"max_open_connections": 5,
"max_connection_lifetime": "5s",
}
Expand Down

0 comments on commit fede390

Please sign in to comment.