]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
make sure we create separate controlsocket for each recursor process
authorBert Hubert <bert.hubert@netherlabs.nl>
Mon, 31 Jan 2011 09:23:10 +0000 (09:23 +0000)
committerBert Hubert <bert.hubert@netherlabs.nl>
Mon, 31 Jan 2011 09:23:10 +0000 (09:23 +0000)
git-svn-id: svn://svn.powerdns.com/pdns/trunk/pdns@1943 d19b8d6e-7fed-0310-83ef-9ca221ded41b

pdns/pdns_recursor.cc
pdns/rec_control.cc

index f6c2c015aa7da9ce75f232a854ad6b299b1e4c79..5e87f19e9961b851f516654472a5df9b00d0359d 100644 (file)
@@ -1,6 +1,6 @@
 /*
     PowerDNS Versatile Database Driven Nameserver
-    Copyright (C) 2003 - 2010  PowerDNS.COM BV
+    Copyright (C) 2003 - 2011  PowerDNS.COM BV
 
     This program is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License version 2 
@@ -657,9 +657,12 @@ void startDoResolve(void *p)
   g_stats.maxMThreadStackUsage = max(MT->getMaxStackUsage(), g_stats.maxMThreadStackUsage);
 }
 
-void makeControlChannelSocket()
+void makeControlChannelSocket(int processNum=-1)
 {
-  string sockname=::arg()["socket-dir"]+"/pdns_recursor.controlsocket";
+  string sockname=::arg()["socket-dir"]+"/pdns_recursor";
+  if(processNum >= 0)
+    sockname += "."+lexical_cast<string>(processNum);
+  sockname+=".controlsocket";
   s_rcc.listen(sockname);
   
 #ifndef WIN32
@@ -1697,7 +1700,8 @@ int serviceMain(int argc, char*argv[])
   makeUDPServerSockets();
   makeTCPServerSockets();
 
-  for(int forks = 0; forks < ::arg().asNum("processes") - 1; ++forks) {
+  int forks;
+  for(forks = 0; forks < ::arg().asNum("processes") - 1; ++forks) {
     if(!fork()) // we are child
       break;
   }
@@ -1717,7 +1721,7 @@ int serviceMain(int argc, char*argv[])
   signal(SIGPIPE,SIG_IGN);
   writePid();
 #endif
-  makeControlChannelSocket();
+  makeControlChannelSocket( ::arg().asNum("processes") > 1 ? forks : -1);
   
   int newgid=0;
   if(!::arg()["setgid"].empty())
@@ -1734,8 +1738,6 @@ int serviceMain(int argc, char*argv[])
   }
 
   Utility::dropPrivs(newuid, newgid);
-  
-  
   g_numThreads = ::arg().asNum("threads") + ::arg().mustDo("pdns-distributes-queries");
   
   makeThreadPipes();
index be79ed4bce02aa56f1aaeb721dd416e5126ecf81..3049dafd797349c9f17246fe0fb976c66a768b5f 100644 (file)
@@ -1,6 +1,6 @@
 /*
     PowerDNS Versatile Database Driven Nameserver
-    Copyright (C) 2006 PowerDNS.COM BV
+    Copyright (C) 2006 - 2011 PowerDNS.COM BV
 
     This program is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License version 2 as 
@@ -39,7 +39,7 @@ static void initArguments(int argc, char** argv)
   arg().set("config-dir","Location of configuration directory (pdns.conf)")=SYSCONFDIR;
 
   arg().set("socket-dir","Where the controlsocket will live")=LOCALSTATEDIR;
-  arg().set("socket-pid","When controlling multiple recursors, the target pid")="";
+  arg().set("process","When controlling multiple recursors, the target process number")="";
   arg().set("timeout", "Number of seconds to wait for the recursor to respond")="5";
   arg().setCmd("help","Provide this helpful message");
 
@@ -49,7 +49,6 @@ static void initArguments(int argc, char** argv)
     cerr<<arg().helpstring(arg()["help"])<<endl;
     exit(99);
   }
-
 }
 
 int main(int argc, char** argv)
@@ -58,9 +57,11 @@ try
   initArguments(argc, argv);
 
   RecursorControlChannel rccS;
-  string sockname="pdns_recursor.controlsocket";
-  if(!arg()["socket-pid"].empty())
-    sockname+="."+arg()["socket-pid"];
+  string sockname="pdns_recursor";
+  if(!arg()["process"].empty())
+    sockname+="."+arg()["process"];
+
+  sockname.append(".controlsocket");
 
   rccS.connect(arg()["socket-dir"], sockname);