fix deadlock with waiting mutex
This commit is contained in:
parent
c713e16ed2
commit
36e9aa49f7
1 changed files with 2 additions and 1 deletions
3
cache/cache.go
vendored
3
cache/cache.go
vendored
|
@ -69,12 +69,13 @@ func (sc *ScoreCache) Add(score float64, ip netip.Addr, ts time.Time) {
|
|||
func (lc *ScoreCache) Get(ip netip.Addr) (ServerScore, error) {
|
||||
now := time.Now()
|
||||
lc.mu.RLock()
|
||||
defer lc.mu.RUnlock()
|
||||
|
||||
cachedScore, ok := lc.scores[ip]
|
||||
if !ok {
|
||||
lc.mu.RUnlock()
|
||||
return ServerScore{}, newCacheMissError()
|
||||
}
|
||||
lc.mu.RUnlock()
|
||||
|
||||
if now.After(cachedScore.expiresAt) {
|
||||
lc.delete(ip)
|
||||
|
|
Loading…
Reference in a new issue