Removed some final traces from SelectFDMplexer from mplexer.hh too.
virtual ~FDMultiplexer()
{}
+ static FDMultiplexer* getMultiplexerSilent();
+
/* tv will be updated to 'now' before run returns */
/* timeout is in ms */
virtual int run(struct timeval* tv, int timeout=500) = 0;
}
};
-class SelectFDMultiplexer : public FDMultiplexer
-{
-public:
- SelectFDMultiplexer()
- {}
- virtual ~SelectFDMultiplexer()
- {}
-
- virtual int run(struct timeval* tv, int timeout=500);
-
- virtual void addFD(callbackmap_t& cbmap, int fd, callbackfunc_t toDo, const funcparam_t& parameter);
- virtual void removeFD(callbackmap_t& cbmap, int fd);
- std::string getName()
- {
- return "select";
- }
-};
#endif
StatBag S;
-SelectFDMultiplexer g_fdm;
+FDMultiplexer* g_fdm;
int g_pdnssocket;
bool g_verbose;
reportAllTypes();
openlog("nproxy", LOG_NDELAY | LOG_PID, LOG_DAEMON);
+ g_fdm = FDMultiplexer::getMultiplexerSilent();
+ if(!g_fdm) {
+ throw std::runtime_error("Could not enable a multiplexer");
+ }
+
po::options_description desc("Allowed options");
desc.add_options()
("help,h", "produce help message")
if(::bind(sock,(sockaddr*) &local, local.getSocklen()) < 0)
throw runtime_error("Binding socket for incoming packets to '"+ local.toStringWithPort()+"': "+stringerror());
- g_fdm.addReadFD(sock, handleOutsideUDPPacket); // add to fdmultiplexer for each socket
+ g_fdm->addReadFD(sock, handleOutsideUDPPacket); // add to fdmultiplexer for each socket
syslogFmt(boost::format("Listening for external notifications on address %s") % local.toStringWithPort());
}
syslogFmt(boost::format("Sending notifications from %s to internal address %s") % originAddress.toString() % pdns.toStringWithPort());
- g_fdm.addReadFD(g_pdnssocket, handleInsideUDPPacket);
+ g_fdm->addReadFD(g_pdnssocket, handleInsideUDPPacket);
int null_fd=open("/dev/null",O_RDWR); /* open stdin */
if(null_fd < 0)
struct timeval now;
for(;;) {
gettimeofday(&now, 0);
- g_fdm.run(&now);
+ g_fdm->run(&now);
// check for notifications that have been outstanding for more than 10 seconds
expireOldNotifications();
}
#include "misc.hh"
#include "namespaces.hh"
+FDMultiplexer* FDMultiplexer::getMultiplexerSilent()
+{
+ FDMultiplexer* ret = nullptr;
+ for(const auto& i : FDMultiplexer::getMultiplexerMap()) {
+ try {
+ ret = i.second();
+ return ret;
+ }
+ catch(const FDMultiplexerException& fe) {
+ }
+ catch(...) {
+ }
+ }
+ return ret;
+}
+
+
class PollFDMultiplexer : public FDMultiplexer
{
public:
(*agent)->handleSNMPQueryEvent(fd);
}
-static FDMultiplexer* getMultiplexer()
-{
- FDMultiplexer* ret = nullptr;
- for(const auto& i : FDMultiplexer::getMultiplexerMap()) {
- try {
- ret = i.second();
- return ret;
- }
- catch(const FDMultiplexerException& fe) {
- }
- catch(...) {
- }
- }
- return ret;
-}
-
#endif /* HAVE_NET_SNMP */
void SNMPAgent::worker()
{
#ifdef HAVE_NET_SNMP
- FDMultiplexer* mplexer = getMultiplexer();
+ FDMultiplexer* mplexer = FDMultiplexer::getMultiplexerSilent();
if (mplexer == nullptr) {
throw std::runtime_error("No FD multiplexer found for the SNMP agent!");
}