From: Rosen Penev Date: Thu, 5 Nov 2020 08:47:27 +0000 (-0800) Subject: clang-tidy: replace bind with lambdas X-Git-Tag: dnsdist-1.6.0-alpha2~55^2~6 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=969e44592a8bfbd06e163f03c711ab0d5616a42f;p=thirdparty%2Fpdns.git clang-tidy: replace bind with lambdas Found with modernize-avoid-bind Signed-off-by: Rosen Penev --- diff --git a/pdns/communicator.cc b/pdns/communicator.cc index 2bbf969db6..19135f8c86 100644 --- a/pdns/communicator.cc +++ b/pdns/communicator.cc @@ -84,11 +84,11 @@ void CommunicatorClass::go() _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(); } diff --git a/pdns/distributor.hh b/pdns/distributor.hh index 38f08005ef..430f098139 100644 --- a/pdns/distributor.hh +++ b/pdns/distributor.hh @@ -170,7 +170,7 @@ templateMultiThreadDistributor::distribute, this, i)); + std::thread t([=](){distribute(i);}); t.detach(); Utility::usleep(50000); // we've overloaded mysql in the past :-) } diff --git a/pdns/dnsdist-lua-actions.cc b/pdns/dnsdist-lua-actions.cc index c488e649fc..dd42747aa4 100644 --- a/pdns/dnsdist-lua-actions.cc +++ b/pdns/dnsdist-lua-actions.cc @@ -160,7 +160,7 @@ TeeAction::TeeAction(const ComboAddress& ca, bool addECS) : d_remote(ca), d_addE 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) { diff --git a/pdns/dnsproxy.cc b/pdns/dnsproxy.cc index 6fb166b113..54eff32097 100644 --- a/pdns/dnsproxy.cc +++ b/pdns/dnsproxy.cc @@ -85,7 +85,7 @@ DNSProxy::DNSProxy(const string &remote) void DNSProxy::go() { - std::thread t(std::bind(&DNSProxy::mainloop, this)); + std::thread t([this](){mainloop();}); t.detach(); } diff --git a/pdns/dynlistener.cc b/pdns/dynlistener.cc index ab10d114da..656538e98f 100644 --- a/pdns/dynlistener.cc +++ b/pdns/dynlistener.cc @@ -204,7 +204,7 @@ DynListener::DynListener(const string &progname) void DynListener::go() { d_ppid=getpid(); - std::thread listener(std::bind(&DynListener::theListener,this)); + std::thread listener([this](){theListener();}); listener.detach(); } diff --git a/pdns/ixfrdist-web.cc b/pdns/ixfrdist-web.cc index ebc456cedb..91596a62d5 100644 --- a/pdns/ixfrdist-web.cc +++ b/pdns/ixfrdist-web.cc @@ -30,7 +30,7 @@ IXFRDistWebServer::IXFRDistWebServer(const ComboAddress &listenAddress, const Ne { 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(); } diff --git a/pdns/tcpreceiver.cc b/pdns/tcpreceiver.cc index ebc7505b9f..1cd35936fe 100644 --- a/pdns/tcpreceiver.cc +++ b/pdns/tcpreceiver.cc @@ -88,7 +88,7 @@ void TCPNameserver::go() g_log<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(); diff --git a/pdns/ws-recursor.cc b/pdns/ws-recursor.cc index c6f521d8fb..76eb2d7731 100644 --- a/pdns/ws-recursor.cc +++ b/pdns/ws-recursor.cc @@ -525,7 +525,7 @@ RecursorWebServer::RecursorWebServer(FDMultiplexer* fdm) 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); @@ -679,7 +679,7 @@ void AsyncServerNewConnectionMT(void *p) { 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() @@ -762,5 +762,5 @@ void AsyncWebServer::go() { auto server = std::dynamic_pointer_cast(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& c){serveConnection(c);}); }