Address review feedback

This commit is contained in:
vishalnayak 2016-08-30 16:36:58 -04:00
parent 29b9295673
commit cdcfa4572f
2 changed files with 7 additions and 3 deletions

View file

@ -61,13 +61,13 @@ func Backend(conf *logical.BackendConfig) (*backend, error) {
salt: salt, salt: salt,
// Create the map of locks to modify the registered roles // Create the map of locks to modify the registered roles
roleLocksMap: map[string]*sync.RWMutex{}, roleLocksMap: make(map[string]*sync.RWMutex, 257),
// Create the map of locks to modify the generated RoleIDs. // Create the map of locks to modify the generated RoleIDs.
roleIDLocksMap: map[string]*sync.RWMutex{}, roleIDLocksMap: make(map[string]*sync.RWMutex, 257),
// Create the map of locks to modify the generated SecretIDs. // Create the map of locks to modify the generated SecretIDs.
secretIDLocksMap: map[string]*sync.RWMutex{}, secretIDLocksMap: make(map[string]*sync.RWMutex, 257),
} }
// Create 256 locks each for managing RoleID and SecretIDs. This will avoid // Create 256 locks each for managing RoleID and SecretIDs. This will avoid

View file

@ -16,6 +16,10 @@ func CreateLocks(p map[string]*sync.RWMutex, count int64) error {
return fmt.Errorf("invalid count: %d", count) return fmt.Errorf("invalid count: %d", count)
} }
if p == nil {
return fmt.Errorf("map of locks is not initialized")
}
for i := int64(0); i < count; i++ { for i := int64(0); i < count; i++ {
p[fmt.Sprintf("%02x", i)] = &sync.RWMutex{} p[fmt.Sprintf("%02x", i)] = &sync.RWMutex{}
} }