packages/net/djbdns/patches/090-tinydns-one-second.patch
nbd 0e7a8e9b4e djbdns: fix compile errors because of wrong ranlib use, also apply Johnny Halfmoon's update to 1.05-5 (#5764)
git-svn-id: svn://svn.openwrt.org/openwrt/packages@17673 3c298f89-4303-0410-b956-a3cf2f4a3e73
2009-09-22 08:45:48 +00:00

41 lines
835 B
Diff

--- a/tdlookup.c
+++ b/tdlookup.c
@@ -280,15 +280,24 @@ static int doit(char *q,char qtype[2])
int respond(char *q,char qtype[2],char ip[4])
{
- int fd;
+ static struct tai cdb_valid = { 0 };
+ static int fd = -1;
+ struct tai one_second;
int r;
char key[6];
tai_now(&now);
- fd = open_read("data.cdb");
- if (fd == -1) return 0;
- cdb_init(&c,fd);
-
+ if (tai_less(&cdb_valid, &now)) {
+ if (fd != -1) {
+ cdb_free(&c);
+ close(fd);
+ }
+ fd = open_read("data.cdb");
+ if (fd == -1) return 0;
+ cdb_init(&c,fd);
+ tai_uint(&one_second, 1);
+ tai_add(&cdb_valid, &now, &one_second);
+ }
byte_zero(clientloc,2);
key[0] = 0;
key[1] = '%';
@@ -312,7 +321,5 @@ int respond(char *q,char qtype[2],char i
r = doit(q,qtype);
- cdb_free(&c);
- close(fd);
return r;
}