Skip to content

Commit cb42789

Browse files
committed
add missing lock
1 parent f6130a8 commit cb42789

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

internal/configfile/config_file.go

+5
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"errors"
55
"path/filepath"
66
"strings"
7+
"sync"
78

89
"github.com/BurntSushi/toml"
910
"github.com/qiniu/go-sdk/v7/internal/env"
@@ -18,6 +19,7 @@ type profileConfig struct {
1819

1920
var (
2021
profileConfigs map[string]*profileConfig
22+
profileConfigsMutex sync.Mutex
2123
ErrInvalidBucketUrl = errors.New("invalid bucket url")
2224
)
2325

@@ -79,6 +81,9 @@ func getProfile() (*profileConfig, error) {
7981
}
8082

8183
func load() error {
84+
profileConfigsMutex.Lock()
85+
defer profileConfigsMutex.Unlock()
86+
8287
if profileConfigs != nil {
8388
return nil
8489
}

0 commit comments

Comments
 (0)