So far records A and AAAA were being connected and stored as a single
*service*. It's possible to handle these records directly without this
service trick and it also provides better control over them (some corner
cases like different TTL values).
Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
struct cache_record *r, *p;
struct cache_service *s, *t;
struct cache_record *r, *p;
struct cache_service *s, *t;
- avl_for_each_element_safe(&records, r, avl, p)
- if (cache_is_expired(r->time, r->ttl, 100))
+ avl_for_each_element_safe(&records, r, avl, p) {
+ if (!cache_is_expired(r->time, r->ttl, 100))
+ continue;
+ /* Records other and A(AAA) are handled as services */
+ if (r->type != TYPE_A && r->type != TYPE_AAAA) {
+ cache_record_free(r);
+ continue;
+ }
+ if (r->refresh >= 100) {
+ continue;
+ }
+ r->refresh += 50;
+ dns_send_question(r->iface, r->record, r->type, 0);
+ }
avl_for_each_element_safe(&services, s, avl, t) {
if (!s->host)
avl_for_each_element_safe(&services, s, avl, t) {
if (!s->host)
continue;
}
s->refresh += 50;
continue;
}
s->refresh += 50;
- if (cache_service_is_host(s)) {
- dns_send_question(s->iface, s->entry, TYPE_A, 0);
- dns_send_question(s->iface, s->entry, TYPE_AAAA, 0);
- } else {
- dns_send_question(s->iface, s->entry, TYPE_PTR, 0);
- }
+ if (cache_service_is_host(s))
+ continue;
+ dns_send_question(s->iface, s->entry, TYPE_PTR, 0);
}
uloop_timeout_set(timeout, 10000);
}
uloop_timeout_set(timeout, 10000);
uint16_t rdlength;
time_t time;
struct interface *iface;
uint16_t rdlength;
time_t time;
struct interface *iface;
};
extern struct avl_tree services;
};
extern struct avl_tree services;