+ /* If so far we weren't successful, and there's
+ * something still pending, then wait for it */
+ if (state != DNS_TRANSACTION_SUCCESS)
+ return;
+
+ /* If we already were successful, then only wait for
+ * other transactions on the same scope to finish. */
+ SET_FOREACH(t, q->transactions, i) {
+ if (t->scope == scope && IN_SET(t->state, DNS_TRANSACTION_PENDING, DNS_TRANSACTION_NULL))
+ return;
+ }
+ }
+
+ if (IN_SET(state, DNS_TRANSACTION_SUCCESS, DNS_TRANSACTION_FAILURE)) {
+ q->answer = dns_answer_ref(answer);
+ q->answer_rcode = rcode;
+ q->answer_ifindex = (scope && scope->link) ? scope->link->ifindex : 0;
+ q->answer_protocol = scope ? scope->protocol : _DNS_PROTOCOL_INVALID;
+ q->answer_family = scope ? scope->family : AF_UNSPEC;
+ }
+
+ dns_query_complete(q, state);