Add some debugging helpers

This commit is contained in:
Frank Denis 2025-02-21 23:56:18 +01:00
parent f052e0ccdf
commit 2d8cfebe8b

View file

@ -117,6 +117,7 @@ func (xTransport *XTransport) saveCachedIP(host string, ip net.IP, ttl time.Dura
xTransport.cachedIPs.Lock() xTransport.cachedIPs.Lock()
xTransport.cachedIPs.cache[host] = item xTransport.cachedIPs.cache[host] = item
xTransport.cachedIPs.Unlock() xTransport.cachedIPs.Unlock()
dlog.Debugf("[%s] IP address [%s] stored to the cache, valid for %v", host, ip, ttl)
} }
// Mark an entry as being updated // Mark an entry as being updated
@ -128,6 +129,7 @@ func (xTransport *XTransport) markUpdatingCachedIP(host string) {
until := now.Add(xTransport.timeout) until := now.Add(xTransport.timeout)
item.updatingUntil = &until item.updatingUntil = &until
xTransport.cachedIPs.cache[host] = item xTransport.cachedIPs.cache[host] = item
dlog.Debugf("[%s] IP addresss marked as updating", host)
} }
xTransport.cachedIPs.Unlock() xTransport.cachedIPs.Unlock()
} }
@ -138,6 +140,7 @@ func (xTransport *XTransport) loadCachedIP(host string) (ip net.IP, expired bool
item, ok := xTransport.cachedIPs.cache[host] item, ok := xTransport.cachedIPs.cache[host]
xTransport.cachedIPs.RUnlock() xTransport.cachedIPs.RUnlock()
if !ok { if !ok {
dlog.Debugf("[%s] IP address not found in the cache", host)
return return
} }
ip = item.ip ip = item.ip
@ -146,6 +149,9 @@ func (xTransport *XTransport) loadCachedIP(host string) (ip net.IP, expired bool
expired = true expired = true
if item.updatingUntil != nil && time.Until(*item.updatingUntil) > 0 { if item.updatingUntil != nil && time.Until(*item.updatingUntil) > 0 {
updating = true updating = true
dlog.Debugf("[%s] IP address is being updated", host)
} else {
dlog.Debugf("[%s] IP address expired, not being updated yet", host)
} }
} }
return return