summaryrefslogtreecommitdiff
path: root/src/resolve/resolved-dns-query.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2014-08-06 16:32:55 +0200
committerLennart Poettering <lennart@poettering.net>2014-08-11 15:06:22 +0200
commit82bd6dddc4a363a9c3c6f41eb46eb171a80dca27 (patch)
tree62c653d001a821d5101e312bcc72076acc4ab019 /src/resolve/resolved-dns-query.c
parent818f766b12e025683cf4fed12b3da2a025bb0b31 (diff)
resolved: destroy outstanding queries if the clients that initiated them die
Diffstat (limited to 'src/resolve/resolved-dns-query.c')
-rw-r--r--src/resolve/resolved-dns-query.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/resolve/resolved-dns-query.c b/src/resolve/resolved-dns-query.c
index ae285ef112..6d77c109b4 100644
--- a/src/resolve/resolved-dns-query.c
+++ b/src/resolve/resolved-dns-query.c
@@ -54,6 +54,7 @@ DnsQuery *dns_query_free(DnsQuery *q) {
dns_answer_unref(q->answer);
sd_bus_message_unref(q->request);
+ sd_bus_track_unref(q->bus_track);
if (q->manager) {
LIST_REMOVE(queries, q->manager->dns_queries, q);
@@ -450,3 +451,33 @@ int dns_query_cname_redirect(DnsQuery *q, const char *name) {
return 0;
}
+
+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 *bus, sd_bus_message *m) {
+ int r;
+
+ assert(q);
+ assert(m);
+
+ if (!q->bus_track) {
+ r = sd_bus_track_new(bus, &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;
+}