Skip to content

Commit

Permalink
dns_cache: fix insert issue.
Browse files Browse the repository at this point in the history
  • Loading branch information
pymumu committed Sep 19, 2023
1 parent 28139d2 commit b7fb501
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/dns_cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -277,18 +277,17 @@ static void _dns_cache_insert_sorted(struct dns_cache *dns_cache, struct list_he
struct dns_cache *tmp = NULL;
struct list_head *insert_head = head;

ttl = dns_cache->info.insert_time + dns_cache->info.ttl;
if (dns_cache_head.last_active_inserted && dns_cache != dns_cache_head.last_active_inserted) {
if (dns_cache_head.last_active_inserted->info.ttl == dns_cache->info.ttl) {
time_t ttl_last =
dns_cache_head.last_active_inserted->info.insert_time + dns_cache_head.last_active_inserted->info.ttl;
if (ttl == ttl_last) {
insert_head = &(dns_cache_head.last_active_inserted->list);
goto out;
} else if (dns_cache_head.last_active_inserted->info.ttl > dns_cache->info.ttl) {
head = &(dns_cache_head.last_active_inserted->list);
insert_head = head;
}
}

/* ascending order */
ttl = dns_cache->info.insert_time + dns_cache->info.ttl;
list_for_each_entry_reverse(tmp, head, list)
{
if ((tmp->info.insert_time + tmp->info.ttl) <= ttl) {
Expand Down

0 comments on commit b7fb501

Please sign in to comment.