Browse Source
Refactor IAM Storage: Multi-File Backend & Unified Interface (#8102)
Refactor IAM Shutdown to use sync.Once for thread safety
pull/8103/head
Chris Lu
1 day ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with
10 additions and
7 deletions
-
weed/s3api/auth_credentials.go
|
|
@ -62,7 +62,8 @@ type IdentityAccessManagement struct { |
|
|
policyEngine *BucketPolicyEngine |
|
|
policyEngine *BucketPolicyEngine |
|
|
|
|
|
|
|
|
// background polling
|
|
|
// background polling
|
|
|
stopChan chan struct{} |
|
|
|
|
|
|
|
|
stopChan chan struct{} |
|
|
|
|
|
shutdownOnce sync.Once |
|
|
|
|
|
|
|
|
// useStaticConfig indicates if the configuration was loaded from a static file
|
|
|
// useStaticConfig indicates if the configuration was loaded from a static file
|
|
|
useStaticConfig bool |
|
|
useStaticConfig bool |
|
|
@ -251,12 +252,14 @@ func (iam *IdentityAccessManagement) pollIamConfigChanges(interval time.Duration |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func (iam *IdentityAccessManagement) Shutdown() { |
|
|
func (iam *IdentityAccessManagement) Shutdown() { |
|
|
if iam.stopChan != nil { |
|
|
|
|
|
close(iam.stopChan) |
|
|
|
|
|
} |
|
|
|
|
|
if iam.credentialManager != nil { |
|
|
|
|
|
iam.credentialManager.Shutdown() |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
iam.shutdownOnce.Do(func() { |
|
|
|
|
|
if iam.stopChan != nil { |
|
|
|
|
|
close(iam.stopChan) |
|
|
|
|
|
} |
|
|
|
|
|
if iam.credentialManager != nil { |
|
|
|
|
|
iam.credentialManager.Shutdown() |
|
|
|
|
|
} |
|
|
|
|
|
}) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// loadEnvironmentVariableCredentials loads AWS credentials from environment variables
|
|
|
// loadEnvironmentVariableCredentials loads AWS credentials from environment variables
|
|
|
|