avoid race on max count reads and writes

This commit is contained in:
Seebs 2020-02-07 13:18:12 -06:00 committed by Matt Jaffee
parent ba7db3028b
commit d742c67317
No known key found for this signature in database
GPG key ID: 08A3DFFF987B11BF
2 changed files with 2 additions and 2 deletions

View file

@ -36,8 +36,8 @@ var mu sync.RWMutex
// SetMaxMapCount sets the maximum map count, and returns the previous maximum.
func SetMaxMapCount(max uint64) uint64 {
prev := maxMapCount
mu.Lock()
prev := maxMapCount
maxMapCount = max
mu.Unlock()
return prev

View file

@ -28,8 +28,8 @@ var maxFileCount uint64 = 500000
var fileMu sync.RWMutex
func SetMaxFileCount(max uint64) uint64 {
prev := maxFileCount
fileMu.Lock()
prev := maxFileCount
maxFileCount = max
fileMu.Unlock()
return prev