mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-08-29 04:07:17 +00:00
chore(weed/storage/backend/s3_backend): remove unused function (#9715)
* chore(weed/storage/backend/s3_backend): remove unused function * fix(s3_backend): cache session under the composite region|endpoint key createSession looked up sessions by region|endpoint but stored them by region alone, so the cache never hit and a new session was built every call. With getSession gone the lock can also drop to a plain Mutex. --------- Co-authored-by: Chris Lu <chris.lu@gmail.com>
This commit is contained in:
co-authored by
Chris Lu
parent
24e664d651
commit
21ab68aa94
@@ -15,17 +15,9 @@ import (
|
||||
|
||||
var (
|
||||
s3Sessions = make(map[string]s3iface.S3API)
|
||||
sessionsLock sync.RWMutex
|
||||
sessionsLock sync.Mutex
|
||||
)
|
||||
|
||||
func getSession(region string) (s3iface.S3API, bool) {
|
||||
sessionsLock.RLock()
|
||||
defer sessionsLock.RUnlock()
|
||||
|
||||
sess, found := s3Sessions[region]
|
||||
return sess, found
|
||||
}
|
||||
|
||||
func createSession(awsAccessKeyId, awsSecretAccessKey, region, endpoint string, forcePathStyle bool) (s3iface.S3API, error) {
|
||||
|
||||
sessionsLock.Lock()
|
||||
@@ -56,7 +48,7 @@ func createSession(awsAccessKeyId, awsSecretAccessKey, region, endpoint string,
|
||||
|
||||
t := s3.New(sess)
|
||||
|
||||
s3Sessions[region] = t
|
||||
s3Sessions[cacheKey] = t
|
||||
|
||||
return t, nil
|
||||
|
||||
|
||||
Reference in New Issue
Block a user