_exit(1);
}
- std::thread mainT(std::bind(&CommunicatorClass::mainloop, this));
+ std::thread mainT([this](){mainloop();});
mainT.detach();
for(int n=0; n < ::arg().asNum("retrieval-threads", 1); ++n) {
- std::thread retrieve(std::bind(&CommunicatorClass::retrievalLoopThread, this));
+ std::thread retrieve([this](){retrievalLoopThread();});
retrieve.detach();
}
g_log<<Logger::Warning<<"About to create "<<n<<" backend threads for UDP"<<endl;
for(int i=0;i<n;i++) {
- std::thread t(std::bind(&MultiThreadDistributor<Answer,Question,Backend>::distribute, this, i));
+ std::thread t([=](){distribute(i);});
t.detach();
Utility::usleep(50000); // we've overloaded mysql in the past :-)
}
try {
SConnect(d_fd, d_remote);
setNonBlocking(d_fd);
- d_worker=std::thread(std::bind(&TeeAction::worker, this));
+ d_worker=std::thread([this](){worker();});
}
catch (...) {
if (d_fd != -1) {
void DNSProxy::go()
{
- std::thread t(std::bind(&DNSProxy::mainloop, this));
+ std::thread t([this](){mainloop();});
t.detach();
}
void DynListener::go()
{
d_ppid=getpid();
- std::thread listener(std::bind(&DynListener::theListener,this));
+ std::thread listener([this](){theListener();});
listener.detach();
}
{
d_ws->setACL(acl);
d_ws->setLogLevel(loglevel);
- d_ws->registerWebHandler("/metrics", std::bind(&IXFRDistWebServer::getMetrics, this, std::placeholders::_1, std::placeholders::_2));
+ d_ws->registerWebHandler("/metrics", [this](HttpRequest* req, HttpResponse* resp){getMetrics(req, resp);});
d_ws->bind();
}
g_log<<Logger::Error<<"TCP server is unable to launch backends - will try again when questions come in: "<<ae.reason<<endl;
}
- std::thread th(std::bind(&TCPNameserver::thread, this));
+ std::thread th([this](){thread();});
th.detach();
}
}
void WebServer::registerApiHandler(const string& url, HandlerFunction handler, bool allowPassword) {
- HandlerFunction f = std::bind(&WebServer::apiWrapper, this, handler, std::placeholders::_1, std::placeholders::_2, allowPassword);
+ auto f = [=](HttpRequest *req, HttpResponse* resp){apiWrapper(handler, req, resp, allowPassword);};
registerBareHandler(url, f);
}
}
void WebServer::registerWebHandler(const string& url, HandlerFunction handler) {
- HandlerFunction f = std::bind(&WebServer::webWrapper, this, handler, std::placeholders::_1, std::placeholders::_2);
+ auto f = [=](HttpRequest *req, HttpResponse *resp){webWrapper(handler, req, resp);};
registerBareHandler(url, f);
}
void AuthWebServer::go()
{
S.doRings();
- std::thread webT(std::bind(&AuthWebServer::webThread, this));
+ std::thread webT([this](){webThread();});
webT.detach();
- std::thread statT(std::bind(&AuthWebServer::statThread, this));
+ std::thread statT([this](){statThread();});
statT.detach();
}
d_ws->registerApiHandler("/api", &apiDiscovery);
}
if (::arg().mustDo("webserver")) {
- d_ws->registerWebHandler("/style.css", std::bind(&AuthWebServer::cssfunction, this, std::placeholders::_1, std::placeholders::_2));
- d_ws->registerWebHandler("/", std::bind(&AuthWebServer::indexfunction, this, std::placeholders::_1, std::placeholders::_2));
+ d_ws->registerWebHandler("/style.css", [this](HttpRequest *req, HttpResponse *resp){cssfunction(req, resp);});
+ d_ws->registerWebHandler("/", [this](HttpRequest *req, HttpResponse *resp){indexfunction(req, resp);});
d_ws->registerWebHandler("/metrics", prometheusMetrics);
}
d_ws->go();
d_ws->bind();
// legacy dispatch
- d_ws->registerApiHandler("/jsonstat", std::bind(&RecursorWebServer::jsonstat, this, std::placeholders::_1, std::placeholders::_2), true);
+ d_ws->registerApiHandler("/jsonstat", [this](HttpRequest* req, HttpResponse* resp){jsonstat(req, resp);}, true);
d_ws->registerApiHandler("/api/v1/servers/localhost/cache/flush", &apiServerCacheFlush);
d_ws->registerApiHandler("/api/v1/servers/localhost/config/allow-from", &apiServerConfigAllowFrom);
d_ws->registerApiHandler("/api/v1/servers/localhost/config", &apiServerConfig);
void AsyncServer::asyncWaitForConnections(FDMultiplexer* fdm, const newconnectioncb_t& callback)
{
d_asyncNewConnectionCallback = callback;
- fdm->addReadFD(d_server_socket.getHandle(), std::bind(&AsyncServer::newConnection, this));
+ fdm->addReadFD(d_server_socket.getHandle(), [this] (int, boost::any&){ newConnection();});
}
void AsyncServer::newConnection()
auto server = std::dynamic_pointer_cast<AsyncServer>(d_server);
if (!server)
return;
- server->asyncWaitForConnections(d_fdm, std::bind(&AsyncWebServer::serveConnection, this, std::placeholders::_1));
+ server->asyncWaitForConnections(d_fdm, [this](const std::shared_ptr<Socket>& c){serveConnection(c);});
}