]> granicus.if.org Git - pdns/commitdiff
Make the TCPNameserver a unique pointer
authorPieter Lexis <pieter.lexis@powerdns.com>
Tue, 28 May 2019 12:17:44 +0000 (14:17 +0200)
committerPieter Lexis <pieter.lexis@powerdns.com>
Mon, 3 Jun 2019 12:59:25 +0000 (14:59 +0200)
pdns/common_startup.cc
pdns/common_startup.hh
pdns/receiver.cc

index b4334b9f26f29543a70ce39ee219ed33f2a482fc..e593cba2f682608831f870e6efa68524f1e74d27 100644 (file)
@@ -52,7 +52,7 @@ DynListener *dl;
 CommunicatorClass Communicator;
 shared_ptr<UDPNameserver> N;
 int avg_latency;
-TCPNameserver *TN;
+unique_ptr<TCPNameserver> TN;
 static vector<DNSDistributor*> g_distributors;
 vector<std::shared_ptr<UDPNameserver> > g_udpReceivers;
 
@@ -606,8 +606,7 @@ void mainthread()
   if(::arg().mustDo("slave") || ::arg().mustDo("master") || !::arg()["forward-notify"].empty())
     Communicator.go(); 
 
-  if(TN)
-    TN->go(); // tcp nameserver launch
+  TN->go(); // tcp nameserver launch
 
   //  fork(); (this worked :-))
   unsigned int max_rthreads= ::arg().asNum("receiver-threads", 1);
index 1e1290ed57f30456169f8f473d8b808ea4834f1a..f19a1f161c5b415b918760bf933cb3913f5c7882 100644 (file)
@@ -46,7 +46,7 @@ extern CommunicatorClass Communicator;
 extern std::shared_ptr<UDPNameserver> N;
 extern vector<std::shared_ptr<UDPNameserver> > g_udpReceivers;
 extern int avg_latency;
-extern TCPNameserver *TN;
+extern std::unique_ptr<TCPNameserver> TN;
 extern ArgvMap & arg( void );
 extern void declareArguments();
 extern void declareStats();
index dfe609c356a93936795c211e283df9d45d1c5873..9d88183153bf2c01e10ad12b562ae92aea5db1c1 100644 (file)
@@ -590,7 +590,7 @@ int main(int argc, char **argv)
       }
     }
 
-    TN = new TCPNameserver;
+    TN = make_unique<TCPNameserver>();
   }
   catch(const ArgException &A) {
     g_log<<Logger::Error<<"Fatal error: "<<A.reason<<endl;