|
@@ -693,6 +693,7 @@ static void parse_reply(char *response, int nbytes)
|
|
|
char result[512];
|
|
char result[512];
|
|
|
unsigned char *ptr;
|
|
unsigned char *ptr;
|
|
|
int i;
|
|
int i;
|
|
|
|
|
+ time_t ttl = 0;
|
|
|
|
|
|
|
|
ptr = (unsigned char *) response;
|
|
ptr = (unsigned char *) response;
|
|
|
memcpy(&header, ptr, 12);
|
|
memcpy(&header, ptr, 12);
|
|
@@ -728,6 +729,8 @@ static void parse_reply(char *response, int nbytes)
|
|
|
reply.type = ntohs(reply.type);
|
|
reply.type = ntohs(reply.type);
|
|
|
reply.rdlength = ntohs(reply.rdlength);
|
|
reply.rdlength = ntohs(reply.rdlength);
|
|
|
reply.ttl = ntohl(reply.ttl);
|
|
reply.ttl = ntohl(reply.ttl);
|
|
|
|
|
+ /* Save the lowest ttl */
|
|
|
|
|
+ if (reply.ttl && (reply.ttl < ttl)) ttl = reply.ttl;
|
|
|
ptr += 10;
|
|
ptr += 10;
|
|
|
if (reply.type == 1) {
|
|
if (reply.type == 1) {
|
|
|
/*fprintf(fp, "ipv4 reply\n");*/
|
|
/*fprintf(fp, "ipv4 reply\n");*/
|
|
@@ -777,8 +780,8 @@ static void parse_reply(char *response, int nbytes)
|
|
|
/* Ok, we have, so now issue the callback with the answers. */
|
|
/* Ok, we have, so now issue the callback with the answers. */
|
|
|
if (prev) prev->next = q->next;
|
|
if (prev) prev->next = q->next;
|
|
|
else query_head = q->next;
|
|
else query_head = q->next;
|
|
|
-
|
|
|
|
|
- cache_add(q->query, &q->answer, reply.ttl);
|
|
|
|
|
|
|
+ cache_add(q->query, &q->answer, ttl);
|
|
|
|
|
+sdprintf("ncache is now: %d", ncache);
|
|
|
|
|
|
|
|
q->callback(q->client_data, q->query, q->answer.list);
|
|
q->callback(q->client_data, q->query, q->answer.list);
|
|
|
answer_free(&q->answer);
|
|
answer_free(&q->answer);
|