resolved: introduce dns_transaction_gcp()
This commit is contained in:
parent
a51a3247e5
commit
29bd6012f1
|
@ -94,7 +94,7 @@ static int dns_query_candidate_next_search_domain(DnsQueryCandidate *c) {
|
|||
}
|
||||
|
||||
static int dns_query_candidate_add_transaction(DnsQueryCandidate *c, DnsResourceKey *key) {
|
||||
DnsTransaction *t;
|
||||
_cleanup_(dns_transaction_gcp) DnsTransaction *t = NULL;
|
||||
int r;
|
||||
|
||||
assert(c);
|
||||
|
@ -105,39 +105,34 @@ static int dns_query_candidate_add_transaction(DnsQueryCandidate *c, DnsResource
|
|||
r = dns_transaction_new(&t, c->scope, key);
|
||||
if (r < 0)
|
||||
return r;
|
||||
} else {
|
||||
if (set_contains(c->transactions, t))
|
||||
return 0;
|
||||
}
|
||||
} else if (set_contains(c->transactions, t))
|
||||
return 0;
|
||||
|
||||
r = set_ensure_allocated(&c->transactions, NULL);
|
||||
if (r < 0)
|
||||
goto gc;
|
||||
return r;
|
||||
|
||||
r = set_ensure_allocated(&t->notify_query_candidates, NULL);
|
||||
if (r < 0)
|
||||
goto gc;
|
||||
return r;
|
||||
|
||||
r = set_ensure_allocated(&t->notify_query_candidates_done, NULL);
|
||||
if (r < 0)
|
||||
goto gc;
|
||||
return r;
|
||||
|
||||
r = set_put(t->notify_query_candidates, c);
|
||||
if (r < 0)
|
||||
goto gc;
|
||||
return r;
|
||||
|
||||
r = set_put(c->transactions, t);
|
||||
if (r < 0) {
|
||||
(void) set_remove(t->notify_query_candidates, c);
|
||||
goto gc;
|
||||
return r;
|
||||
}
|
||||
|
||||
t->clamp_ttl = c->query->clamp_ttl;
|
||||
TAKE_PTR(t);
|
||||
return 1;
|
||||
|
||||
gc:
|
||||
dns_transaction_gc(t);
|
||||
return r;
|
||||
}
|
||||
|
||||
static int dns_query_candidate_go(DnsQueryCandidate *c) {
|
||||
|
|
|
@ -1800,7 +1800,7 @@ static int dns_transaction_find_cyclic(DnsTransaction *t, DnsTransaction *aux) {
|
|||
}
|
||||
|
||||
static int dns_transaction_add_dnssec_transaction(DnsTransaction *t, DnsResourceKey *key, DnsTransaction **ret) {
|
||||
DnsTransaction *aux;
|
||||
_cleanup_(dns_transaction_gcp) DnsTransaction *aux = NULL;
|
||||
int r;
|
||||
|
||||
assert(t);
|
||||
|
@ -1835,32 +1835,28 @@ static int dns_transaction_add_dnssec_transaction(DnsTransaction *t, DnsResource
|
|||
|
||||
r = set_ensure_allocated(&t->dnssec_transactions, NULL);
|
||||
if (r < 0)
|
||||
goto gc;
|
||||
return r;;
|
||||
|
||||
r = set_ensure_allocated(&aux->notify_transactions, NULL);
|
||||
if (r < 0)
|
||||
goto gc;
|
||||
return r;
|
||||
|
||||
r = set_ensure_allocated(&aux->notify_transactions_done, NULL);
|
||||
if (r < 0)
|
||||
goto gc;
|
||||
return r;
|
||||
|
||||
r = set_put(t->dnssec_transactions, aux);
|
||||
if (r < 0)
|
||||
goto gc;
|
||||
return r;
|
||||
|
||||
r = set_put(aux->notify_transactions, t);
|
||||
if (r < 0) {
|
||||
(void) set_remove(t->dnssec_transactions, aux);
|
||||
goto gc;
|
||||
return r;
|
||||
}
|
||||
|
||||
*ret = aux;
|
||||
*ret = TAKE_PTR(aux);
|
||||
return 1;
|
||||
|
||||
gc:
|
||||
dns_transaction_gc(aux);
|
||||
return r;
|
||||
}
|
||||
|
||||
static int dns_transaction_request_dnssec_rr(DnsTransaction *t, DnsResourceKey *key) {
|
||||
|
|
|
@ -138,6 +138,8 @@ int dns_transaction_new(DnsTransaction **ret, DnsScope *s, DnsResourceKey *key);
|
|||
DnsTransaction* dns_transaction_free(DnsTransaction *t);
|
||||
|
||||
bool dns_transaction_gc(DnsTransaction *t);
|
||||
DEFINE_TRIVIAL_CLEANUP_FUNC(DnsTransaction*, dns_transaction_gc);
|
||||
|
||||
int dns_transaction_go(DnsTransaction *t);
|
||||
|
||||
void dns_transaction_process_reply(DnsTransaction *t, DnsPacket *p);
|
||||
|
|
|
@ -162,7 +162,7 @@ static int dns_zone_link_item(DnsZone *z, DnsZoneItem *i) {
|
|||
}
|
||||
|
||||
static int dns_zone_item_probe_start(DnsZoneItem *i) {
|
||||
DnsTransaction *t;
|
||||
_cleanup_(dns_transaction_gcp) DnsTransaction *t = NULL;
|
||||
int r;
|
||||
|
||||
assert(i);
|
||||
|
@ -185,23 +185,22 @@ static int dns_zone_item_probe_start(DnsZoneItem *i) {
|
|||
|
||||
r = set_ensure_allocated(&t->notify_zone_items, NULL);
|
||||
if (r < 0)
|
||||
goto gc;
|
||||
return r;
|
||||
|
||||
r = set_ensure_allocated(&t->notify_zone_items_done, NULL);
|
||||
if (r < 0)
|
||||
goto gc;
|
||||
return r;
|
||||
|
||||
r = set_put(t->notify_zone_items, i);
|
||||
if (r < 0)
|
||||
goto gc;
|
||||
return r;
|
||||
|
||||
i->probe_transaction = t;
|
||||
t->probing = true;
|
||||
i->probe_transaction = TAKE_PTR(t);
|
||||
|
||||
if (t->state == DNS_TRANSACTION_NULL) {
|
||||
|
||||
if (i->probe_transaction->state == DNS_TRANSACTION_NULL) {
|
||||
i->block_ready++;
|
||||
r = dns_transaction_go(t);
|
||||
r = dns_transaction_go(i->probe_transaction);
|
||||
i->block_ready--;
|
||||
|
||||
if (r < 0) {
|
||||
|
@ -212,10 +211,6 @@ static int dns_zone_item_probe_start(DnsZoneItem *i) {
|
|||
|
||||
dns_zone_item_notify(i);
|
||||
return 0;
|
||||
|
||||
gc:
|
||||
dns_transaction_gc(t);
|
||||
return r;
|
||||
}
|
||||
|
||||
int dns_zone_put(DnsZone *z, DnsScope *s, DnsResourceRecord *rr, bool probe) {
|
||||
|
|
Loading…
Reference in New Issue