]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
remove last use of select() so we can make the owner of ticket 408 happy and launch...
authorBert Hubert <bert.hubert@netherlabs.nl>
Wed, 3 Oct 2012 19:20:47 +0000 (19:20 +0000)
committerBert Hubert <bert.hubert@netherlabs.nl>
Wed, 3 Oct 2012 19:20:47 +0000 (19:20 +0000)
git-svn-id: svn://svn.powerdns.com/pdns/trunk/pdns@2740 d19b8d6e-7fed-0310-83ef-9ca221ded41b

pdns/nameserver.cc
pdns/nameserver.hh

index 60affa1440c91a17f356e7e945cf3c1ace99e380..34ea30df8baa0c4c96a43018e2da255698e3f54d 100644 (file)
@@ -125,7 +125,11 @@ void UDPNameserver::bindIPv4()
     d_highfd=max(s,d_highfd);
     d_sockets.push_back(s);
     L<<Logger::Error<<"UDP server bound to "<<inet_ntoa(locala.sin_addr)<<":"<<::arg().asNum("local-port")<<endl;
-    FD_SET(s, &d_rfds);
+    struct pollfd pfd;
+    pfd.fd = s;
+    pfd.events = POLL_IN;
+    pfd.revents = 0;
+    d_rfds.push_back(pfd);
   }
 }
 
@@ -159,8 +163,13 @@ void UDPNameserver::bindIPv6()
     }
     d_highfd=max(s,d_highfd);
     d_sockets.push_back(s);
+    struct pollfd pfd;
+    pfd.fd = s;
+    pfd.events = POLL_IN;
+    pfd.revents = 0;
+    d_rfds.push_back(pfd);
     L<<Logger::Error<<"UDPv6 server bound to "<<locala.toStringWithPort()<<endl;
-    FD_SET(s, &d_rfds);
+    
   }
 #endif // WIN32
 }
@@ -168,7 +177,6 @@ void UDPNameserver::bindIPv6()
 UDPNameserver::UDPNameserver()
 {
   d_highfd=0;
-  FD_ZERO(&d_rfds);  
   if(!::arg()["local-address"].empty())
     bindIPv4();
   if(!::arg()["local-ipv6"].empty())
index 30f164353c1410c7ca792eb3e5a81ecf1909b936..ae6b113ffbebdf282d7df7014f916669917f01ce 100644 (file)
@@ -19,7 +19,7 @@
 #define NAMESERVER_HH
 
 #ifndef WIN32
-# include <sys/select.h>
+# include <poll.h>
 # include <sys/types.h>
 # include <sys/socket.h>
 # include <netinet/in.h>
@@ -31,6 +31,7 @@
 #endif // WIN32
 
 #include <vector>
+#include <boost/foreach.hpp>
 #include "statbag.hh"
 #include "namespaces.hh"
 
@@ -79,7 +80,7 @@ private:
   vector<int> d_sockets;
   void bindIPv4();
   void bindIPv6();
-  fd_set d_rfds;
+  vector<pollfd> d_rfds;
   int d_highfd;
 };
 
@@ -96,13 +97,16 @@ inline DNSPacket *UDPNameserver::receive(DNSPacket *prefilled)
   memset( &remote, 0, sizeof( remote ));
   addrlen=sizeof(remote);  
   if(d_sockets.size()>1) {
-    fd_set rfds=d_rfds;
+    BOOST_FOREACH(struct pollfd &pfd, d_rfds) {
+      pfd.events = POLL_IN;
+      pfd.revents = 0;
+    }
     
-    select(d_highfd+1, &rfds, 0, 0,  0); // blocks
-
-    for(vector<int>::const_iterator i=d_sockets.begin();i!=d_sockets.end();++i) {
-      if(FD_ISSET(*i, &rfds)) {
-        sock=*i;
+    poll(&d_rfds[0], d_rfds.size(), -1);
+  
+    BOOST_FOREACH(struct pollfd &pfd, d_rfds) {
+      if(pfd.revents & POLL_IN) {
+        sock=pfd.fd;
         addrlen=sizeof(remote);
         
         len=0;