Move lock to not surround pieces which don't use any internal members. (#7779)

Previously the read/write lock applied both for gateway use cases as
well the object store use case. Nothing from sys is touched or looked
at in the gateway usecase though, so we don't need to lock. Don't lock
to make the gateway policy getting a little more efficient, particularly
as where this is called from (checkRequestAuthType) is quite common.
master
Cody Maloney 6 years ago committed by kannappanr
parent 510ec153b9
commit 7b8beecc81
  1. 6
      cmd/policy.go

@ -85,9 +85,6 @@ func (sys *PolicySys) Remove(bucketName string) {
// IsAllowed - checks given policy args is allowed to continue the Rest API.
func (sys *PolicySys) IsAllowed(args policy.Args) bool {
sys.RLock()
defer sys.RUnlock()
if globalIsGateway {
// When gateway is enabled, no cached value
// is used to validate bucket policies.
@ -99,6 +96,9 @@ func (sys *PolicySys) IsAllowed(args policy.Args) bool {
}
}
} else {
sys.RLock()
defer sys.RUnlock()
// If policy is available for given bucket, check the policy.
if p, found := sys.bucketPolicyMap[args.BucketName]; found {
return p.IsAllowed(args)

Loading…
Cancel
Save