mirror of
https://github.com/XTLS/Xray-core.git
synced 2026-07-02 09:48:43 +00:00
fix CacheCleanup
This commit is contained in:
@@ -46,6 +46,10 @@ func NewCacheController(name string, disableCache bool, serveStale bool, serveEx
|
|||||||
// CacheCleanup clears expired items from cache
|
// CacheCleanup clears expired items from cache
|
||||||
func (c *CacheController) CacheCleanup() error {
|
func (c *CacheController) CacheCleanup() error {
|
||||||
now := time.Now()
|
now := time.Now()
|
||||||
|
if c.serveStale && c.serveExpiredTTL != 0 {
|
||||||
|
now = now.Add(time.Duration(c.serveExpiredTTL) * time.Second)
|
||||||
|
}
|
||||||
|
|
||||||
c.Lock()
|
c.Lock()
|
||||||
defer c.Unlock()
|
defer c.Unlock()
|
||||||
|
|
||||||
@@ -115,7 +119,9 @@ func (c *CacheController) updateIP(req *dnsRequest, ipRec *IPRecord) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
c.Unlock()
|
c.Unlock()
|
||||||
common.Must(c.cacheCleanup.Start())
|
if !c.serveStale || c.serveExpiredTTL != 0 {
|
||||||
|
common.Must(c.cacheCleanup.Start())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *CacheController) findIPsForDomain(domain string, option dns_feature.IPOption) ([]net.IP, int32, error) {
|
func (c *CacheController) findIPsForDomain(domain string, option dns_feature.IPOption) ([]net.IP, int32, error) {
|
||||||
|
|||||||
Reference in New Issue
Block a user