Преглед изворни кода

* When cancelling the query due to timeout of not recieving all answers,
send all of the answers which did come to the callback.

Bryan Drewery пре 17 година
родитељ
комит
36e056474e
1 измењених фајлова са 10 додато и 1 уклоњено
  1. 10 1
      src/adns.c

+ 10 - 1
src/adns.c

@@ -830,7 +830,16 @@ int egg_dns_cancel(int id, int issue_callback)
 	if (prev) prev->next = q->next;
 	else query_head = q->next;
 	sdprintf("Cancelling query: %s", q->query);
-	if (issue_callback) q->callback(q->id, q->client_data, q->query, NULL);
+	if (issue_callback) {
+		if (q->answer.len > 0) {
+			cache_add(q->query, &q->answer);
+
+			q->callback(q->id, q->client_data, q->query, q->answer.list);
+			answer_free(&q->answer);
+		} else {
+			q->callback(q->id, q->client_data, q->query, NULL);
+		}
+	}
 	if (q->ip)
 		free(q->ip);
 	free(q->query);