mirror of
https://github.com/libevent/libevent.git
synced 2025-01-09 00:56:20 +08:00
evdns fix NULL res clearing the cache entry
Signed-off-by: Kirill Rodriguez <theoden8@tutamail.com> Signed-off-by: Kirill Rodriguez <theoden8@gmail.com>
This commit is contained in:
parent
8572c273e9
commit
822502d72d
20
evdns.c
20
evdns.c
@ -5383,15 +5383,17 @@ evdns_cache_write(struct evdns_base *dns_base, char *nodename, struct evutil_add
|
||||
log(EVDNS_LOG_DEBUG, "Ejecting old cache for %s", nodename);
|
||||
evdns_cache_free(cache);
|
||||
}
|
||||
cache = mm_calloc(1, sizeof(struct evdns_cache));
|
||||
cache->base = dns_base;
|
||||
cache->name = mm_strdup(nodename);
|
||||
cache->ai = evutil_dup_addrinfo_(res);
|
||||
SPLAY_INSERT(evdns_tree, &cache->base->cache_root, cache);
|
||||
evtimer_assign(&cache->ev_timeout, dns_base->event_base, evdns_ttl_expired, cache);
|
||||
timerclear(&tv);
|
||||
tv.tv_sec = ttl;
|
||||
evtimer_add(&cache->ev_timeout, &tv);
|
||||
if (res) {
|
||||
cache = mm_calloc(1, sizeof(struct evdns_cache));
|
||||
cache->base = dns_base;
|
||||
cache->name = mm_strdup(nodename);
|
||||
cache->ai = evutil_dup_addrinfo_(res);
|
||||
SPLAY_INSERT(evdns_tree, &cache->base->cache_root, cache);
|
||||
evtimer_assign(&cache->ev_timeout, dns_base->event_base, evdns_ttl_expired, cache);
|
||||
timerclear(&tv);
|
||||
tv.tv_sec = ttl;
|
||||
evtimer_add(&cache->ev_timeout, &tv);
|
||||
}
|
||||
EVDNS_UNLOCK(dns_base);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user