From 8edfedf16fdcae591b1437701abf87fc8d76dcad Mon Sep 17 00:00:00 2001 From: Bert Hubert Date: Wed, 18 Nov 2009 21:54:46 +0000 Subject: [PATCH] phase out last use of select() in powerdns auth server, which prevented us from binding >500 Ip addresses or so git-svn-id: svn://svn.powerdns.com/pdns/trunk/pdns@1443 d19b8d6e-7fed-0310-83ef-9ca221ded41b --- pdns/tcpreceiver.cc | 31 ++++++++++++++++++++----------- pdns/tcpreceiver.hh | 3 ++- 2 files changed, 22 insertions(+), 12 deletions(-) diff --git a/pdns/tcpreceiver.cc b/pdns/tcpreceiver.cc index 0b6ae2090..86035d250 100644 --- a/pdns/tcpreceiver.cc +++ b/pdns/tcpreceiver.cc @@ -25,7 +25,7 @@ #include #include "tcpreceiver.hh" #include "sstuff.hh" - +#include #include #include @@ -526,7 +526,6 @@ TCPNameserver::TCPNameserver() #ifndef WIN32 signal(SIGPIPE,SIG_IGN); #endif // WIN32 - FD_ZERO(&d_rfds); for(vector::const_iterator laddr=locals.begin();laddr!=locals.end();++laddr) { int s=socket(AF_INET,SOCK_STREAM,0); @@ -550,7 +549,13 @@ TCPNameserver::TCPNameserver() listen(s,128); L<::const_iterator i=d_sockets.begin();i!=d_sockets.end();++i) { - if(FD_ISSET(*i, &rfds)) { - sock=*i; + BOOST_FOREACH(const struct pollfd& pfd, d_prfds) { + if(pfd.revents == POLLIN) { + sock = pfd.fd; addrlen=sizeof(remote); if((fd=accept(sock, (sockaddr*)&remote, &addrlen))<0) { diff --git a/pdns/tcpreceiver.hh b/pdns/tcpreceiver.hh index 6ec85c58b..250b35176 100644 --- a/pdns/tcpreceiver.hh +++ b/pdns/tcpreceiver.hh @@ -25,6 +25,7 @@ #include "packethandler.hh" #include #include +#include #ifndef WIN32 # include @@ -64,7 +65,7 @@ private: vectord_sockets; int d_highfd; - fd_set d_rfds; + vector d_prfds; static int s_timeout; }; -- 2.49.0