1
0
mirror of https://github.com/systemd/systemd.git synced 2025-02-10 17:57:40 +03:00

resolved: make dns_transaction_gc return a pointer

_gc() does cleanup if it is possible. So far it returned a bool to
signal if it succeeded (false on success). When working on the resolved
code I had to look at the definition every time, because the (arguably
reversed) calling convention is unobvious. So let's return a pointer
(non-NULL: gc has not been done, NULL: gc has been done).

This fits nicely with the standard to return a pointer from all free
functions obviously.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek 2021-02-16 14:10:28 +01:00
parent d3b56a0cad
commit 1f38830153
2 changed files with 8 additions and 8 deletions

View File

@ -141,23 +141,23 @@ DnsTransaction* dns_transaction_free(DnsTransaction *t) {
DEFINE_TRIVIAL_CLEANUP_FUNC(DnsTransaction*, dns_transaction_free);
bool dns_transaction_gc(DnsTransaction *t) {
DnsTransaction* dns_transaction_gc(DnsTransaction *t) {
assert(t);
/* Returns !NULL if we can't gc yet. */
if (t->block_gc > 0)
return true;
return t;
if (set_isempty(t->notify_query_candidates) &&
set_isempty(t->notify_query_candidates_done) &&
set_isempty(t->notify_zone_items) &&
set_isempty(t->notify_zone_items_done) &&
set_isempty(t->notify_transactions) &&
set_isempty(t->notify_transactions_done)) {
dns_transaction_free(t);
return false;
}
set_isempty(t->notify_transactions_done))
return dns_transaction_free(t);
return true;
return t;
}
static uint16_t pick_new_id(Manager *m) {

View File

@ -143,7 +143,7 @@ struct DnsTransaction {
int dns_transaction_new(DnsTransaction **ret, DnsScope *s, DnsResourceKey *key, DnsPacket *bypass, uint64_t flags);
DnsTransaction* dns_transaction_free(DnsTransaction *t);
bool dns_transaction_gc(DnsTransaction *t);
DnsTransaction* dns_transaction_gc(DnsTransaction *t);
DEFINE_TRIVIAL_CLEANUP_FUNC(DnsTransaction*, dns_transaction_gc);
int dns_transaction_go(DnsTransaction *t);