Răsfoiți Sursa

* 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 ani în urmă
părinte
comite
36e056474e
1 a modificat fișierele cu 10 adăugiri și 1 ștergeri
  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;
 	if (prev) prev->next = q->next;
 	else query_head = q->next;
 	else query_head = q->next;
 	sdprintf("Cancelling query: %s", q->query);
 	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)
 	if (q->ip)
 		free(q->ip);
 		free(q->ip);
 	free(q->query);
 	free(q->query);