From: Pieter Lexis Date: Fri, 16 Nov 2018 12:38:45 +0000 (+0100) Subject: ixfrdist: wrap WebServer in a unique_ptr X-Git-Tag: auth-4.2.0-alpha1~31^2~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7e31534e0be10885b99c5865b712dab4c969ef10;p=thirdparty%2Fpdns.git ixfrdist: wrap WebServer in a unique_ptr --- diff --git a/pdns/ixfrdist-web.cc b/pdns/ixfrdist-web.cc index 93f610aa7c..751bb716fa 100644 --- a/pdns/ixfrdist-web.cc +++ b/pdns/ixfrdist-web.cc @@ -28,8 +28,7 @@ string doGetStats(); IXFRDistWebServer::IXFRDistWebServer(const ComboAddress &listenAddress, const NetmaskGroup &acl) { - // TODO wrap in smart pointer - d_ws = new WebServer(listenAddress.toString() , listenAddress.getPort()); + d_ws = std::unique_ptr(new WebServer(listenAddress.toString(), listenAddress.getPort())); d_ws->setACL(acl); d_ws->registerWebHandler("/metrics", boost::bind(&IXFRDistWebServer::getMetrics, this, _1, _2)); d_ws->bind(); diff --git a/pdns/ixfrdist-web.hh b/pdns/ixfrdist-web.hh index 7b2871453f..580e976344 100644 --- a/pdns/ixfrdist-web.hh +++ b/pdns/ixfrdist-web.hh @@ -30,7 +30,7 @@ class IXFRDistWebServer void go(); private: - WebServer *d_ws; + std::unique_ptr d_ws; // All endpoints void getMetrics(HttpRequest* req, HttpResponse* resp); diff --git a/pdns/ixfrdist.cc b/pdns/ixfrdist.cc index 41d0b152fc..e37fb356cf 100644 --- a/pdns/ixfrdist.cc +++ b/pdns/ixfrdist.cc @@ -1255,8 +1255,8 @@ int main(int argc, char** argv) { } } - auto ws = IXFRDistWebServer(config["webserver-address"].as(), wsACL); - std::thread (&IXFRDistWebServer::go, ws).detach(); + // Launch the webserver! + std::thread(&IXFRDistWebServer::go, IXFRDistWebServer(config["webserver-address"].as(), wsACL)).detach(); } int newuid = 0;