🐛 [Bug-Fix]: add lock to avoid data race #2360 (#2368)

Update memory.go

The fix is to protect the access to s.db and save the result to a local variable.
pull/2371/head
UtopiaGitHub 2023-03-14 18:41:48 +08:00 committed by GitHub
parent 01d39dbb81
commit 678728de6d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 0 deletions

View File

@ -139,5 +139,7 @@ func (s *Storage) gc() {
// Return database client
func (s *Storage) Conn() map[string]entry {
s.mux.RLock()
defer s.mux.RUnlock()
return s.db
}