diff options
-rw-r--r-- | src/resolve/resolved-bus.c | 37 | ||||
-rw-r--r-- | src/resolve/resolved-dns-query.c | 37 | ||||
-rw-r--r-- | src/resolve/resolved-dns-query.h | 2 |
3 files changed, 39 insertions, 37 deletions
diff --git a/src/resolve/resolved-bus.c b/src/resolve/resolved-bus.c index 1f4c8b95ea..4a36c554a9 100644 --- a/src/resolve/resolved-bus.c +++ b/src/resolve/resolved-bus.c @@ -24,6 +24,39 @@ BUS_DEFINE_PROPERTY_GET_ENUM(bus_property_get_resolve_support, resolve_support, ResolveSupport); +static int query_on_bus_track(sd_bus_track *t, void *userdata) { + DnsQuery *q = userdata; + + assert(t); + assert(q); + + if (!DNS_TRANSACTION_IS_LIVE(q->state)) + return 0; + + log_debug("Client of active query vanished, aborting query."); + dns_query_complete(q, DNS_TRANSACTION_ABORTED); + return 0; +} + +static int dns_query_bus_track(DnsQuery *q, sd_bus_message *m) { + int r; + + assert(q); + assert(m); + + if (!q->bus_track) { + r = sd_bus_track_new(sd_bus_message_get_bus(m), &q->bus_track, query_on_bus_track, q); + if (r < 0) + return r; + } + + r = sd_bus_track_add_sender(q->bus_track, m); + if (r < 0) + return r; + + return 0; +} + static int reply_query_state(DnsQuery *q) { switch (q->state) { @@ -1689,7 +1722,7 @@ static int bus_method_reset_server_features(sd_bus_message *message, void *userd return sd_bus_reply_method_return(message, NULL); } -static int on_bus_track(sd_bus_track *t, void *userdata) { +static int dnssd_service_on_bus_track(sd_bus_track *t, void *userdata) { DnssdService *s = userdata; assert(t); @@ -1862,7 +1895,7 @@ static int bus_method_register_service(sd_bus_message *message, void *userdata, if (r < 0) return r; - r = sd_bus_track_new(sd_bus_message_get_bus(message), &bus_track, on_bus_track, service); + r = sd_bus_track_new(sd_bus_message_get_bus(message), &bus_track, dnssd_service_on_bus_track, service); if (r < 0) return r; diff --git a/src/resolve/resolved-dns-query.c b/src/resolve/resolved-dns-query.c index cd943ab843..ec57474351 100644 --- a/src/resolve/resolved-dns-query.c +++ b/src/resolve/resolved-dns-query.c @@ -473,14 +473,13 @@ int dns_query_make_auxiliary(DnsQuery *q, DnsQuery *auxiliary_for) { return 0; } -static void dns_query_complete(DnsQuery *q, DnsTransactionState state) { +void dns_query_complete(DnsQuery *q, DnsTransactionState state) { assert(q); assert(!DNS_TRANSACTION_IS_LIVE(state)); assert(DNS_TRANSACTION_IS_LIVE(q->state)); - /* Note that this call might invalidate the query. Callers - * should hence not attempt to access the query or transaction - * after calling this function. */ + /* Note that this call might invalidate the query. Callers should hence not attempt to access the + * query or transaction after calling this function. */ q->state = state; @@ -987,36 +986,6 @@ int dns_query_process_cname(DnsQuery *q) { return DNS_QUERY_RESTARTED; /* We restarted the query for a new cname */ } -static int on_bus_track(sd_bus_track *t, void *userdata) { - DnsQuery *q = userdata; - - assert(t); - assert(q); - - log_debug("Client of active query vanished, aborting query."); - dns_query_complete(q, DNS_TRANSACTION_ABORTED); - return 0; -} - -int dns_query_bus_track(DnsQuery *q, sd_bus_message *m) { - int r; - - assert(q); - assert(m); - - if (!q->bus_track) { - r = sd_bus_track_new(sd_bus_message_get_bus(m), &q->bus_track, on_bus_track, q); - if (r < 0) - return r; - } - - r = sd_bus_track_add_sender(q->bus_track, m); - if (r < 0) - return r; - - return 0; -} - DnsQuestion* dns_query_question_for_protocol(DnsQuery *q, DnsProtocol protocol) { assert(q); diff --git a/src/resolve/resolved-dns-query.h b/src/resolve/resolved-dns-query.h index 5dd439c193..d48cc8eb6d 100644 --- a/src/resolve/resolved-dns-query.h +++ b/src/resolve/resolved-dns-query.h @@ -112,7 +112,7 @@ void dns_query_ready(DnsQuery *q); int dns_query_process_cname(DnsQuery *q); -int dns_query_bus_track(DnsQuery *q, sd_bus_message *m); +void dns_query_complete(DnsQuery *q, DnsTransactionState state); DnsQuestion* dns_query_question_for_protocol(DnsQuery *q, DnsProtocol protocol); |