Skip to content

Commit

Permalink
🐛 [Bug-Fix]: add lock to avoid data race #2360 (#2368)
Browse files Browse the repository at this point in the history
Update memory.go

The fix is to protect the access to s.db and save the result to a local variable.
  • Loading branch information
yanke-xu committed Mar 14, 2023
1 parent 01d39db commit 678728d
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions internal/storage/memory/memory.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

0 comments on commit 678728d

Please sign in to comment.