[cvslog] (2004-12-22 19:03:18 UTC) Module eggdrop1.9: Change committed!

cvslog cvs at tsss.org
Wed Dec 22 13:03:18 CST 2004


CVSROOT    : /usr/local/cvsroot
Module     : eggdrop1.9
Commit time: 2004-12-22 19:03:18 UTC
Commited by: Bryan Drewery <lordares at shatow.net>

Modified files:
     lib/eggdrop/dns.c

Log message:



---------------------- diff included ----------------------
Index: eggdrop1.9/lib/eggdrop/dns.c
diff -u eggdrop1.9/lib/eggdrop/dns.c:1.11 eggdrop1.9/lib/eggdrop/dns.c:1.12
--- eggdrop1.9/lib/eggdrop/dns.c:1.11	Wed Dec 22 11:40:54 2004
+++ eggdrop1.9/lib/eggdrop/dns.c	Wed Dec 22 13:03:08 2004
@@ -18,7 +18,7 @@
  */
 
 #ifndef lint
-static const char rcsid[] = "$Id: dns.c,v 1.11 2004/12/22 17:40:54 lordares Exp $";
+static const char rcsid[] = "$Id: dns.c,v 1.12 2004/12/22 19:03:08 lordares Exp $";
 #endif
 
 #include <eggdrop/eggdrop.h>
@@ -28,6 +28,7 @@
 
 typedef struct {
 	char **list;
+	time_t ttl;
 	int len;
 } dns_answer_t;
 
@@ -339,7 +340,7 @@
 	cache = (dns_cache_t *) realloc(cache, (ncache+1)*sizeof(*cache));
 }
 
-static void cache_add(const char *query, dns_answer_t *answer, time_t ttl)
+static void cache_add(const char *query, dns_answer_t *answer)
 {
 	int i;
 
@@ -348,7 +349,7 @@
 	answer_init(&cache[ncache].answer);
 	for (i = 0; i < answer->len; i++)
 		answer_add(&cache[ncache].answer, answer->list[i]);
-	cache[ncache].expiretime = timer_get_now_sec(NULL) + ttl;
+	cache[ncache].expiretime = timer_get_now_sec(NULL) + answer->ttl;
 	ncache++;
 }
 
@@ -580,7 +581,6 @@
 	char result[512];
 	unsigned char *ptr;
 	int i;
-	time_t ttl = 0;
 
 	ptr = (unsigned char *)response;
 	memcpy(&header, ptr, 12);
@@ -615,7 +615,8 @@
 		reply.rdlength = ntohs(reply.rdlength);
 		reply.ttl = ntohl(reply.ttl);
 		/* Cache the lowest ttl */
-		if (reply.ttl && (reply.ttl < ttl)) ttl = reply.ttl
+		if (reply.ttl && ((!q->answer.ttl) || (q->answer.ttl > reply.ttl))) q->answer.ttl = reply.ttl;
+
 		ptr += 10;
 		if (reply.type == 1) {
 			/*fprintf(fp, "ipv4 reply\n");*/
@@ -666,7 +667,7 @@
 	if (prev) prev->next = q->next;
 	else query_head = q->next;
 
-	cache_add(q->query, &q->answer, ttl);
+	cache_add(q->query, &q->answer);
 
 	q->callback(q->client_data, q->query, q->answer.list);
 	answer_free(&q->answer);
----------------------- End of diff -----------------------



More information about the Changes mailing list