]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Kill a few naked pointers
authorOtto Moerbeek <otto.moerbeek@open-xchange.com>
Tue, 25 Jan 2022 12:44:41 +0000 (13:44 +0100)
committerOtto Moerbeek <otto.moerbeek@open-xchange.com>
Fri, 4 Feb 2022 10:06:16 +0000 (11:06 +0100)
pdns/pdns_recursor.cc
pdns/recursordist/rec-main.cc
pdns/recursordist/rec-main.hh
pdns/ws-recursor.cc

index 625050fb68074f6b7b07eb21d8d7ca80e501bd8b..3314b0164b1e8c1affc4e4f67d907d4dd7d6cc1f 100644 (file)
@@ -52,7 +52,7 @@ std::unique_ptr<MemRecursorCache> g_recCache;
 std::unique_ptr<NegCache> g_negCache;
 
 thread_local std::unique_ptr<RecursorPacketCache> t_packetCache;
-thread_local FDMultiplexer* t_fdm{nullptr};
+thread_local std::unique_ptr<FDMultiplexer> t_fdm;
 thread_local std::unique_ptr<addrringbuf_t> t_remotes, t_servfailremotes, t_largeanswerremotes, t_bogusremotes;
 thread_local std::unique_ptr<boost::circular_buffer<pair<DNSName, uint16_t>>> t_queryring, t_servfailqueryring, t_bogusqueryring;
 thread_local std::shared_ptr<NetmaskGroup> t_allowFrom;
index bcaf57fffa59cc39d57282deb993cc14547adebd..97420d942259a9ea155243e46f8041929c9e5cad 100644 (file)
@@ -1977,11 +1977,9 @@ void* recursorThread()
     checkFrameStreamExport(luaconfsLocal);
 #endif
 
-    PacketID pident;
+    t_fdm = unique_ptr<FDMultiplexer>(getMultiplexer());
 
-    t_fdm = getMultiplexer();
-
-    RecursorWebServer* rws = nullptr;
+    std::unique_ptr<RecursorWebServer> 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<RecursorWebServer>(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) {
index e8554badd932e7a2b22d22cf342d6c5bca24865e..49e7fd2d219f5ecdda7c9b011a26ebeb39d66961 100644 (file)
@@ -139,7 +139,7 @@ struct DNSComboWriter
   std::map<std::string, RecursorLua4::MetaValue> d_meta;
 };
 
-extern thread_local FDMultiplexer* t_fdm;
+extern thread_local unique_ptr<FDMultiplexer> t_fdm;
 extern uint16_t g_minUdpSourcePort;
 extern uint16_t g_maxUdpSourcePort;
 
index 8a01b41eb342df4a7219ff8c72dd6388eb1cf905..1e3f628c44c05dcbe1e461b232b27eebfb721cf5 100644 (file)
@@ -45,8 +45,6 @@
 #include "tcpiohandler.hh"
 #include "rec-main.hh"
 
-extern thread_local FDMultiplexer* t_fdm;
-
 using json11::Json;
 
 void productServerStatisticsFetch(map<string, string>& out)