Skip to content

Commit

Permalink
fix(api): eliminate potential memory leak (#854)
Browse files Browse the repository at this point in the history
  • Loading branch information
favonia committed Aug 6, 2024
1 parent fc8accb commit b9c7327
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions internal/api/cloudflare_records.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ func (h CloudflareHandle) ListZones(ctx context.Context, ppfmt pp.PP, name strin
}
}

h.cache.listZones.DeleteExpired()
h.cache.listZones.Set(name, ids, ttlcache.DefaultTTL)

return ids, true
Expand All @@ -83,6 +84,7 @@ zoneSearch:
case 0: // len(zones) == 0
continue zoneSearch
case 1: // len(zones) == 1
h.cache.zoneOfDomain.DeleteExpired()
h.cache.zoneOfDomain.Set(domain.DNSNameASCII(), zones[0], ttlcache.DefaultTTL)
return zones[0], true
default: // len(zones) > 1
Expand Down Expand Up @@ -141,6 +143,7 @@ func (h CloudflareHandle) ListRecords(ctx context.Context, ppfmt pp.PP,
}
}

h.cache.listRecords[ipNet].DeleteExpired()
h.cache.listRecords[ipNet].Set(domain.DNSNameASCII(), rmap, ttlcache.DefaultTTL)

return rmap, false, true
Expand Down

0 comments on commit b9c7327

Please sign in to comment.