From a5040968b14bff853ba45b9092f260a37a406ada Mon Sep 17 00:00:00 2001 From: Otto Moerbeek Date: Tue, 25 Jan 2022 13:44:41 +0100 Subject: [PATCH] Kill a few naked pointers --- pdns/pdns_recursor.cc | 2 +- pdns/recursordist/rec-main.cc | 12 ++++-------- pdns/recursordist/rec-main.hh | 2 +- pdns/ws-recursor.cc | 2 -- 4 files changed, 6 insertions(+), 12 deletions(-) diff --git a/pdns/pdns_recursor.cc b/pdns/pdns_recursor.cc index 625050fb68..3314b0164b 100644 --- a/pdns/pdns_recursor.cc +++ b/pdns/pdns_recursor.cc @@ -52,7 +52,7 @@ std::unique_ptr g_recCache; std::unique_ptr g_negCache; thread_local std::unique_ptr t_packetCache; -thread_local FDMultiplexer* t_fdm{nullptr}; +thread_local std::unique_ptr t_fdm; thread_local std::unique_ptr t_remotes, t_servfailremotes, t_largeanswerremotes, t_bogusremotes; thread_local std::unique_ptr>> t_queryring, t_servfailqueryring, t_bogusqueryring; thread_local std::shared_ptr t_allowFrom; diff --git a/pdns/recursordist/rec-main.cc b/pdns/recursordist/rec-main.cc index bcaf57fffa..97420d9422 100644 --- a/pdns/recursordist/rec-main.cc +++ b/pdns/recursordist/rec-main.cc @@ -1977,11 +1977,9 @@ void* recursorThread() checkFrameStreamExport(luaconfsLocal); #endif - PacketID pident; + t_fdm = unique_ptr(getMultiplexer()); - t_fdm = getMultiplexer(); - - RecursorWebServer* rws = nullptr; + std::unique_ptr rws; t_fdm->addReadFD(threadInfo.pipes.readToThread, handlePipeRequest); @@ -1989,7 +1987,7 @@ void* recursorThread() if (::arg().mustDo("webserver")) { g_log << Logger::Warning << "Enabling web server" << endl; try { - rws = new RecursorWebServer(t_fdm); + rws = make_unique(t_fdm.get()); } catch (const PDNSException& e) { g_log << Logger::Error << "Unable to start the internal web server: " << e.reason << endl; @@ -2025,7 +2023,7 @@ void* recursorThread() unsigned int maxTcpClients = ::arg().asNum("max-tcp-clients"); - bool listenOnTCP(true); + bool listenOnTCP{true}; time_t last_stat = 0; time_t last_carbon = 0, last_lua_maintenance = 0; @@ -2104,8 +2102,6 @@ void* recursorThread() } } } - delete rws; - delete t_fdm; return nullptr; } catch (PDNSException& ae) { diff --git a/pdns/recursordist/rec-main.hh b/pdns/recursordist/rec-main.hh index e8554badd9..49e7fd2d21 100644 --- a/pdns/recursordist/rec-main.hh +++ b/pdns/recursordist/rec-main.hh @@ -139,7 +139,7 @@ struct DNSComboWriter std::map d_meta; }; -extern thread_local FDMultiplexer* t_fdm; +extern thread_local unique_ptr t_fdm; extern uint16_t g_minUdpSourcePort; extern uint16_t g_maxUdpSourcePort; diff --git a/pdns/ws-recursor.cc b/pdns/ws-recursor.cc index 8a01b41eb3..1e3f628c44 100644 --- a/pdns/ws-recursor.cc +++ b/pdns/ws-recursor.cc @@ -45,8 +45,6 @@ #include "tcpiohandler.hh" #include "rec-main.hh" -extern thread_local FDMultiplexer* t_fdm; - using json11::Json; void productServerStatisticsFetch(map& out) -- 2.47.2