pthread_mutex_t TCPNameserver::s_plock = PTHREAD_MUTEX_INITIALIZER;
Semaphore *TCPNameserver::d_connectionroom_sem;
+unsigned int TCPNameserver::d_maxTCPConnections = 0;
PacketHandler *TCPNameserver::s_P;
NetmaskGroup TCPNameserver::d_ng;
size_t TCPNameserver::d_maxTransactionsPerConn;
"', do = " <<packet->d_dnssecOk <<", bufsize = "<< packet->getMaxReplyLen()<<": ";
}
+ if(PC.enabled()) {
+ if(packet->couldBeCached() && PC.get(packet.get(), cached.get())) { // short circuit - does the PacketCache recognize this question?
+ if(logDNSQueries)
+ g_log<<"packetcache HIT"<<endl;
+ cached->setRemote(&packet->d_remote);
+ cached->d.id=packet->d.id;
+ cached->d.rd=packet->d.rd; // copy in recursion desired bit
+ cached->commitD(); // commit d to the packet inlined
- if(packet->couldBeCached() && PC.get(packet.get(), cached.get())) { // short circuit - does the PacketCache recognize this question?
+ sendPacket(cached, fd); // presigned, don't do it again
+ continue;
+ }
if(logDNSQueries)
- g_log<<"packetcache HIT"<<endl;
- cached->setRemote(&packet->d_remote);
- cached->d.id=packet->d.id;
- cached->d.rd=packet->d.rd; // copy in recursion desired bit
- cached->commitD(); // commit d to the packet inlined
-
- sendPacket(cached, fd); // presigned, don't do it again
- continue;
+ g_log<<"packetcache MISS"<<endl;
}
- if(logDNSQueries)
- g_log<<"packetcache MISS"<<endl;
{
Lock l(&s_plock);
if(!s_P) {
while(B->get(rr))
nsset.insert(DNSName(rr.content));
for(const auto & j: nsset) {
- vector<string> nsips=fns.lookup(j, s_P->getBackend(),q->qdomain);
+ vector<string> nsips=fns.lookup(j, s_P->getBackend());
for(vector<string>::const_iterator k=nsips.begin();k!=nsips.end();++k) {
// cerr<<"got "<<*k<<" from AUTO-NS"<<endl;
if(*k == q->getRemote().toString())
bool d_auth;
};
- DNSZoneRecord makeEditedDNSZRFromSOAData(DNSSECKeeper& dk, const SOAData& sd)
- {
- SOAData edited = sd;
- edited.serial = calculateEditSOA(sd.serial, dk, sd.qname);
-
- DNSRecord soa;
- soa.d_name = sd.qname;
- soa.d_type = QType::SOA;
- soa.d_ttl = sd.ttl;
- soa.d_place = DNSResourceRecord::ANSWER;
- soa.d_content = makeSOAContent(edited);
-
- DNSZoneRecord dzr;
- dzr.auth = true;
- dzr.dr = soa;
-
- return dzr;
- }
-
shared_ptr<DNSPacket> getFreshAXFRPacket(shared_ptr<DNSPacket> q)
{
shared_ptr<DNSPacket> ret = shared_ptr<DNSPacket>(q->replyPacket());
// sem_init(&d_connectionroom_sem,0,::arg().asNum("max-tcp-connections"));
d_connectionroom_sem = new Semaphore( ::arg().asNum( "max-tcp-connections" ));
+ d_maxTCPConnections = ::arg().asNum( "max-tcp-connections" );
d_tid=0;
vector<string>locals;
stringtok(locals,::arg()["local-address"]," ,");
}
+unsigned int TCPNameserver::numTCPConnections()
+{
+ int room;
+ d_connectionroom_sem->getValue( &room);
+ return d_maxTCPConnections - room;
+}