aboutsummaryrefslogtreecommitdiff
path: root/dnscache.c
diff options
context:
space:
mode:
authorHenryk Plötz <henryk@ploetzli.ch>2014-10-03 20:12:35 +0200
committerHenryk Plötz <henryk@ploetzli.ch>2014-10-03 20:14:00 +0200
commitb741c385597d43d38c3858c816732ddc0ad1eab1 (patch)
treef26d076c4683c6e81b6c63eb3b6d6d5eef5f53a6 /dnscache.c
parentbe7456f41bce09cffcaf75487b369c4d60263af2 (diff)
downloadtinydnssec-b741c385597d43d38c3858c816732ddc0ad1eab1.tar.gz
tinydnssec-b741c385597d43d38c3858c816732ddc0ad1eab1.tar.bz2
Apply 0004-dnscache.c-allow-a-maximum-of-20-concurrent-outgoing.diff
SHA1 138118548db85af9ff3193fb58e923c6ca877956, contained in djbdns_1.05-8ubuntu1.diff.gz Source was http://archive.ubuntu.com/ubuntu/pool/universe/d/djbdns/djbdns_1.05-8ubuntu1.diff.gz, SHA1 0813f9370548f8699d442207bdd36ae9ef567b15
Diffstat (limited to 'dnscache.c')
-rw-r--r--dnscache.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/dnscache.c b/dnscache.c
index abcba69..2366ecc 100644
--- a/dnscache.c
+++ b/dnscache.c
@@ -72,11 +72,15 @@ static struct udpclient {
} u[MAXUDP];
int uactive = 0;
+#define MAXSOA 20
+int soaactive = 0;
+
void u_drop(int j)
{
if (!u[j].active) return;
log_querydrop(&u[j].active);
u[j].active = 0; --uactive;
+ if (byte_equal(u[j].q.type,2,DNS_T_SOA)) --soaactive;
}
void u_respond(int j)
@@ -87,6 +91,7 @@ void u_respond(int j)
socket_send6(udp53,response,response_len,u[j].ip,u[j].port,u[j].scope_id);
log_querydone(&u[j].active,response_len);
u[j].active = 0; --uactive;
+ if (byte_equal(u[j].q.type,2,DNS_T_SOA)) --soaactive;
}
void u_new(void)
@@ -125,6 +130,16 @@ void u_new(void)
x->active = ++numqueries; ++uactive;
log_query(&x->active,x->ip,x->port,x->id,q,qtype);
+
+ if (byte_equal(qtype,2,DNS_T_SOA)) {
+ if (soaactive >= MAXSOA) {
+ log_querydropmaxsoa(&x->active);
+ x->active = 0; --uactive;
+ return;
+ }
+ ++soaactive;
+ }
+
switch(query_start(&x->q,q,qtype,qclass,myipoutgoing,interface)) {
case -1:
u_drop(j);