Skip to content
Commits on Source (1)
  • Ainar Garipov's avatar
    Pull request: 5190-fix-panic · 6d9de39a
    Ainar Garipov authored
    Updates AdguardTeam/AdGuardHome#4695.
    Updates AdguardTeam/AdGuardHome#5190.
    
    Squashed commit of the following:
    
    commit 881fbc00e038ec30a9bf52f53a590e38687a399a
    Author: Ainar Garipov <A.Garipov@AdGuard.COM>
    Date:   Fri Dec 2 15:28:47 2022 +0300
    
        proxy: fix panic
    6d9de39a
......@@ -318,7 +318,9 @@ func (c *cache) clearItems() {
c.itemsLock.Lock()
defer c.itemsLock.Unlock()
c.items.Clear()
if c.items != nil {
c.items.Clear()
}
}
// clearItemsWithSubnet empties the subnet cache.
......@@ -326,7 +328,9 @@ func (c *cache) clearItemsWithSubnet() {
c.itemsWithSubnetLock.Lock()
defer c.itemsWithSubnetLock.Unlock()
c.itemsWithSubnet.Clear()
if c.itemsWithSubnet != nil {
c.itemsWithSubnet.Clear()
}
}
// cacheTTL returns the number of seconds for which m is valid to be cached.
......
......@@ -146,8 +146,8 @@ func TestCache_expired(t *testing.T) {
key := msgToKey(reply)
data := (&cacheItem{
m: reply,
ttl: tc.ttl,
u: testUpsAddr,
ttl: tc.ttl,
}).pack()
testCache.items.Set(key, data)
t.Cleanup(testCache.items.Clear)
......