+ /* One of the transactions is successful, let's use
+ * it, and copy its data out */
+ if (t->state == DNS_TRANSACTION_SUCCESS) {
+ DnsAnswer *a;
+
+ if (t->received) {
+ rcode = DNS_PACKET_RCODE(t->received);
+ a = t->received->answer;
+ } else {
+ rcode = t->cached_rcode;
+ a = t->cached;
+ }
+
+ if (state == DNS_TRANSACTION_SUCCESS) {
+ DnsAnswer *merged;
+
+ merged = dns_answer_merge(answer, a);
+ if (!merged) {
+ dns_query_complete(q, DNS_TRANSACTION_RESOURCES);
+ return;
+ }
+
+ dns_answer_unref(answer);
+ answer = merged;
+ } else {
+ dns_answer_unref(answer);
+ answer = dns_answer_ref(a);
+ }
+
+ scope = t->scope;
+ state = DNS_TRANSACTION_SUCCESS;
+ continue;
+ }