[packages] tor-alpha: update to 0.2.2.22-alpha, add archive mirror
[openwrt/svn-archive/archive.git] / net / djbdns / patches / 090-tinydns-one-second.patch
1 --- a/tdlookup.c
2 +++ b/tdlookup.c
3 @@ -280,15 +280,24 @@ static int doit(char *q,char qtype[2])
4
5 int respond(char *q,char qtype[2],char ip[4])
6 {
7 - int fd;
8 + static struct tai cdb_valid = { 0 };
9 + static int fd = -1;
10 + struct tai one_second;
11 int r;
12 char key[6];
13
14 tai_now(&now);
15 - fd = open_read("data.cdb");
16 - if (fd == -1) return 0;
17 - cdb_init(&c,fd);
18 -
19 + if (tai_less(&cdb_valid, &now)) {
20 + if (fd != -1) {
21 + cdb_free(&c);
22 + close(fd);
23 + }
24 + fd = open_read("data.cdb");
25 + if (fd == -1) return 0;
26 + cdb_init(&c,fd);
27 + tai_uint(&one_second, 1);
28 + tai_add(&cdb_valid, &now, &one_second);
29 + }
30 byte_zero(clientloc,2);
31 key[0] = 0;
32 key[1] = '%';
33 @@ -312,7 +321,5 @@ int respond(char *q,char qtype[2],char i
34
35 r = doit(q,qtype);
36
37 - cdb_free(&c);
38 - close(fd);
39 return r;
40 }