Move some mutexes around

This commit is contained in:
Jeff Mitchell 2016-05-05 12:53:27 -04:00
parent f689e4712d
commit c69ba40d05
2 changed files with 7 additions and 6 deletions

View file

@ -65,6 +65,9 @@ func (b *backend) configTidyIdentities(s logical.Storage) (*tidyWhitelistIdentit
}
func (b *backend) pathConfigTidyIdentitiesCreateUpdate(req *logical.Request, data *framework.FieldData) (*logical.Response, error) {
b.configMutex.Lock()
defer b.configMutex.Unlock()
configEntry, err := b.configTidyIdentities(req.Storage)
if err != nil {
return nil, err
@ -87,9 +90,6 @@ func (b *backend) pathConfigTidyIdentitiesCreateUpdate(req *logical.Request, dat
configEntry.DisablePeriodicTidy = data.Get("disable_periodic_tidy").(bool)
}
b.configMutex.Lock()
defer b.configMutex.Unlock()
entry, err := logical.StorageEntryJSON("config/tidy/identities", configEntry)
if err != nil {
return nil, err

View file

@ -16,6 +16,7 @@ func pathConfigTidyRoleTags(b *backend) *framework.Path {
Description: `The amount of extra time that must have passed beyond the roletag
expiration, before it is removed from the backend storage.`,
},
"disable_periodic_tidy": &framework.FieldSchema{
Type: framework.TypeBool,
Default: false,
@ -66,6 +67,9 @@ func (b *backend) configTidyRoleTags(s logical.Storage) (*tidyBlacklistRoleTagCo
}
func (b *backend) pathConfigTidyRoleTagsCreateUpdate(req *logical.Request, data *framework.FieldData) (*logical.Response, error) {
b.configMutex.Lock()
defer b.configMutex.Unlock()
configEntry, err := b.configTidyRoleTags(req.Storage)
if err != nil {
return nil, err
@ -86,9 +90,6 @@ func (b *backend) pathConfigTidyRoleTagsCreateUpdate(req *logical.Request, data
configEntry.DisablePeriodicTidy = data.Get("disable_periodic_tidy").(bool)
}
b.configMutex.Lock()
defer b.configMutex.Unlock()
entry, err := logical.StorageEntryJSON("config/tidy/roletags", configEntry)
if err != nil {
return nil, err