- return r;
-
- dns_query_transaction_set_state(t, DNS_QUERY_PENDING);
- return 1;
-}
-
-DnsQuery *dns_query_free(DnsQuery *q) {
- unsigned n;
-
- if (!q)
- return NULL;
-
- sd_bus_message_unref(q->request);
- dns_packet_unref(q->received);
- sd_event_source_unref(q->timeout_event_source);
-
- while (q->transactions)
- dns_query_transaction_free(q->transactions);
-
- if (q->manager)
- LIST_REMOVE(queries, q->manager->dns_queries, q);
-
- for (n = 0; n < q->n_keys; n++)
- free(q->keys[n].name);
- free(q->keys);
- free(q);
-
- return NULL;
-}
-
-int dns_query_new(Manager *m, DnsQuery **ret, DnsResourceKey *keys, unsigned n_keys) {
- _cleanup_(dns_query_freep) DnsQuery *q = NULL;
- const char *name = NULL;
-
- assert(m);
-
- if (n_keys <= 0 || n_keys >= 65535)
- return -EINVAL;
-
- assert(keys);
-
- q = new0(DnsQuery, 1);
- if (!q)
- return -ENOMEM;
-
- q->keys = new(DnsResourceKey, n_keys);
- if (!q->keys)
- return -ENOMEM;
-
- for (q->n_keys = 0; q->n_keys < n_keys; q->n_keys++) {
- q->keys[q->n_keys].class = keys[q->n_keys].class;
- q->keys[q->n_keys].type = keys[q->n_keys].type;
- q->keys[q->n_keys].name = strdup(keys[q->n_keys].name);
- if (!q->keys[q->n_keys].name)
- return -ENOMEM;