X-Git-Url: http://git.ipfire.org/?a=blobdiff_plain;f=pdns%2Ftcpreceiver.cc;h=c925766966087e01eb4a7de600049bd86a509010;hb=d322f9312dda0603b0c3bddaa4e2e124990f524e;hp=706305c87aa718be343b0308dee1ce78b9383ade;hpb=9704e9a835c1d4714859490873a4535aa602db25;p=thirdparty%2Fpdns.git diff --git a/pdns/tcpreceiver.cc b/pdns/tcpreceiver.cc index 706305c87a..c925766966 100644 --- a/pdns/tcpreceiver.cc +++ b/pdns/tcpreceiver.cc @@ -68,6 +68,7 @@ extern StatBag S; 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; @@ -358,20 +359,21 @@ void *TCPNameserver::doConnection(void *data) "', do = " <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"<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"<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"< getFreshAXFRPacket(shared_ptr q) { shared_ptr ret = shared_ptr(q->replyPacket()); @@ -1213,6 +1196,7 @@ TCPNameserver::TCPNameserver() // 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; vectorlocals; stringtok(locals,::arg()["local-address"]," ,"); @@ -1352,7 +1336,7 @@ void TCPNameserver::thread() int sock=-1; for(const pollfd& pfd : d_prfds) { - if(pfd.revents == POLLIN) { + if(pfd.revents & POLLIN) { sock = pfd.fd; remote.sin4.sin_family = AF_INET6; addrlen=remote.getSocklen(); @@ -1405,3 +1389,9 @@ void TCPNameserver::thread() } +unsigned int TCPNameserver::numTCPConnections() +{ + int room; + d_connectionroom_sem->getValue( &room); + return d_maxTCPConnections - room; +}