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);
}
}
}
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
}
UDPNameserver::UDPNameserver()
{
d_highfd=0;
- FD_ZERO(&d_rfds);
if(!::arg()["local-address"].empty())
bindIPv4();
if(!::arg()["local-ipv6"].empty())
#define NAMESERVER_HH
#ifndef WIN32
-# include <sys/select.h>
+# include <poll.h>
# include <sys/types.h>
# include <sys/socket.h>
# include <netinet/in.h>
#endif // WIN32
#include <vector>
+#include <boost/foreach.hpp>
#include "statbag.hh"
#include "namespaces.hh"
vector<int> d_sockets;
void bindIPv4();
void bindIPv6();
- fd_set d_rfds;
+ vector<pollfd> d_rfds;
int d_highfd;
};
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;