handle racy updates to globalSite config (#19750)

```
==================
WARNING: DATA RACE
Read at 0x0000082be990 by goroutine 205:
  github.com/minio/minio/cmd.setCommonHeaders()

Previous write at 0x0000082be990 by main goroutine:
  github.com/minio/minio/cmd.lookupConfigs()
```
This commit is contained in:
Harshavardhana
2024-05-16 16:13:47 -07:00
committed by GitHub
parent aa3fde1784
commit 08d74819b6
31 changed files with 95 additions and 62 deletions

View File

@@ -750,7 +750,7 @@ func newTestStreamingRequest(method, urlStr string, dataLength, chunkSize int64,
func assembleStreamingChunks(req *http.Request, body io.ReadSeeker, chunkSize int64,
secretKey, signature string, currTime time.Time) (*http.Request, error,
) {
regionStr := globalSite.Region
regionStr := globalSite.Region()
var stream []byte
var buffer []byte
body.Seek(0, 0)
@@ -858,7 +858,7 @@ func preSignV4(req *http.Request, accessKeyID, secretAccessKey string, expires i
return errors.New("Presign cannot be generated without access and secret keys")
}
region := globalSite.Region
region := globalSite.Region()
date := UTCNow()
scope := getScope(date, region)
credential := fmt.Sprintf("%s/%s", accessKeyID, scope)
@@ -986,7 +986,7 @@ func signRequestV4(req *http.Request, accessKey, secretKey string) error {
}
sort.Strings(headers)
region := globalSite.Region
region := globalSite.Region()
// Get canonical headers.
var buf bytes.Buffer