mirror of
https://github.com/systemd/systemd-stable.git
synced 2025-01-25 06:03:40 +03:00
resolved: add DNS_RESOURCE_KEY_REPLACE
This commit is contained in:
parent
7daeec3e6c
commit
5731844157
@ -568,8 +568,7 @@ int dns_answer_remove_by_answer_keys(DnsAnswer **a, DnsAnswer *b) {
|
||||
|
||||
/* Let's remember this entry's RR key, to optimize the loop a bit: if we have an RRset with
|
||||
* more than one item then we don't need to remove the key multiple times */
|
||||
dns_resource_key_unref(prev);
|
||||
prev = dns_resource_key_ref(item->rr->key);
|
||||
DNS_RESOURCE_KEY_REPLACE(prev, dns_resource_key_ref(item->rr->key));
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -380,8 +380,7 @@ static void dns_cache_item_update_positive(
|
||||
|
||||
DNS_RR_REPLACE(i->rr, dns_resource_record_ref(rr));
|
||||
|
||||
dns_resource_key_unref(i->key);
|
||||
i->key = dns_resource_key_ref(rr->key);
|
||||
DNS_RESOURCE_KEY_REPLACE(i->key, dns_resource_key_ref(rr->key));
|
||||
|
||||
DNS_ANSWER_REPLACE(i->answer, dns_answer_ref(answer));
|
||||
|
||||
|
@ -360,13 +360,10 @@ bool dns_resource_key_reduce(DnsResourceKey **a, DnsResourceKey **b) {
|
||||
return false;
|
||||
|
||||
/* Keep the one which already has more references. */
|
||||
if ((*a)->n_ref > (*b)->n_ref) {
|
||||
dns_resource_key_unref(*b);
|
||||
*b = dns_resource_key_ref(*a);
|
||||
} else {
|
||||
dns_resource_key_unref(*a);
|
||||
*a = dns_resource_key_ref(*b);
|
||||
}
|
||||
if ((*a)->n_ref > (*b)->n_ref)
|
||||
DNS_RESOURCE_KEY_REPLACE(*b, dns_resource_key_ref(*a));
|
||||
else
|
||||
DNS_RESOURCE_KEY_REPLACE(*a, dns_resource_key_ref(*b));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -292,6 +292,15 @@ int dns_resource_key_new_append_suffix(DnsResourceKey **ret, DnsResourceKey *key
|
||||
DnsResourceKey* dns_resource_key_new_consume(uint16_t class, uint16_t type, char *name);
|
||||
DnsResourceKey* dns_resource_key_ref(DnsResourceKey *key);
|
||||
DnsResourceKey* dns_resource_key_unref(DnsResourceKey *key);
|
||||
|
||||
#define DNS_RESOURCE_KEY_REPLACE(a, b) \
|
||||
do { \
|
||||
typeof(a)* _a = &(a); \
|
||||
typeof(b) _b = (b); \
|
||||
dns_resource_key_unref(*_a); \
|
||||
*_a = _b; \
|
||||
} while(0)
|
||||
|
||||
const char* dns_resource_key_name(const DnsResourceKey *key);
|
||||
bool dns_resource_key_is_address(const DnsResourceKey *key);
|
||||
bool dns_resource_key_is_dnssd_ptr(const DnsResourceKey *key);
|
||||
|
Loading…
x
Reference in New Issue
Block a user