]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
revert setpgrp changes
authorKees Monshouwer <mind04@monshouwer.org>
Sun, 31 Aug 2014 10:12:39 +0000 (12:12 +0200)
committermind04 <mind04@monshouwer.org>
Sun, 31 Aug 2014 12:32:30 +0000 (14:32 +0200)
Revert "Terminate pdns process after SIGINT" 5c663d99afcdd3c26d5744a47911840e16265b6d.
Revert "PDNS should always be the leader of the process group" 1a3bbc1bafea87169a1ed78f78a964ba06231b11.
Revert "Clean up after the pdns_server-instance" 6f8e772b634101a19106e23f20c5358357adf6d8.
Revert "Clean up after DynListener crash" 233f08a1de5508ca4ee67de9bc90045c2cd0cf63.
Revert "pdns: Kill all spawned processes" ee443da2d3ca2f831bbc2347088498890417ec13.
Revert "no systemd kill signals required, pdns_control take care of this" efd72fc50f71df4cd7036d960fa1814c15e4f230.

contrib/systemd-pdns.service
pdns/dynlistener.cc
pdns/pdns-recursor.init.d
pdns/receiver.cc

index 0238e8a4fdc788e870d9e944e7bdca343b7e3229..aab895c70e8ed1c1a0f7e7d120f76cd41fce687e 100644 (file)
@@ -6,7 +6,6 @@ After=network-online.target mysqld.service postgresql.service slapd.service
 Type=forking
 ExecStart=/usr/sbin/pdns_server --daemon
 ExecStop=/usr/bin/pdns_control quit
-KillMode=none
 Restart=on-failure
 RestartSec=2
 PrivateTmp=true
index ad556ee83a86ca2c53da9a4cda4968f368a36363..8e6dc142e779cfeaa5fa01cbc6a51fce8523ba70 100644 (file)
@@ -195,8 +195,6 @@ void *DynListener::theListenerHelper(void *p)
   DynListener *us=static_cast<DynListener *>(p);
   us->theListener();
   L<<Logger::Error<<"Control listener aborted, please file a bug!"<<endl;
-  L<<Logger::Error<<"Taking down the Parent PGRP ("<<getpgid(us->d_ppid)<<") with it"<<endl;
-  kill(-getpgid(us->d_ppid),SIGKILL);
   return 0;
 }
 
index df7e7701c453a4cc69e7936b39acf930bfa2edf7..157a881ab3b2643e3476141307dc2558810825ce 100755 (executable)
@@ -57,7 +57,7 @@ case "$1" in
 
        force-stop)
                echo -n "Stopping PowerDNS recursing nameserver: "
-               killall -v -g -9 pdns_server
+               killall -v -9 pdns_server
                echo "killed"
        ;;
 
index af38f2bbaeebbbd8a217de9198e9628e911cce9f..d2b16fbd397eba8342eb153941002343054c7f9c 100644 (file)
@@ -118,11 +118,9 @@ static void takedown(int i)
 {
   if(cpid) {
     L<<Logger::Error<<"Guardian is killed, taking down children with us"<<endl;
-  } else {
-    L<<Logger::Error<<"PDNS instance is going down, taking children with us"<<endl;
+    kill(cpid,SIGKILL);
+    exit(0);
   }
-  kill(-getpgid(cpid),SIGKILL);
-  exit(0);
 }
 
 static void writePid(void)
@@ -142,7 +140,8 @@ pthread_mutex_t g_guardian_lock = PTHREAD_MUTEX_INITIALIZER;
 // The next two methods are not in dynhandler.cc because they use a few items declared in this file.
 static string DLCycleHandler(const vector<string>&parts, pid_t ppid)
 {
-  kill(-getpgid(cpid), SIGKILL);
+  kill(cpid, SIGKILL); // why?
+  kill(cpid, SIGKILL); // why?
   sleep(1);
   return "ok";
 }
@@ -196,6 +195,7 @@ static int guardian(int argc, char **argv)
   string progname=argv[0];
 
   bool first=true;
+  cpid=0;
 
   pthread_mutex_lock(&g_guardian_lock);
 
@@ -215,15 +215,12 @@ static int guardian(int argc, char **argv)
     setbuf(g_fp,0); // no buffering please, confuses select
 
     if(!(pid=fork())) { // child
+      signal(SIGTERM, SIG_DFL);
+
       signal(SIGHUP, SIG_DFL);
       signal(SIGUSR1, SIG_DFL);
       signal(SIGUSR2, SIG_DFL);
 
-      // Set different pgrp for this child,
-      // so we could kill all of it's children
-      // with one kill call
-      setpgid(getpid(), 0);
-
       char **const newargv=new char*[argc+2];
       int n;
 
@@ -268,6 +265,8 @@ static int guardian(int argc, char **argv)
 
       if(first) {
         first=false;
+        signal(SIGTERM, takedown);
+
         signal(SIGHUP, SIG_IGN);
         signal(SIGUSR1, SIG_IGN);
         signal(SIGUSR2, SIG_IGN);
@@ -312,7 +311,8 @@ static int guardian(int argc, char **argv)
         L<<Logger::Error<<"Our pdns instance exited with code "<<ret<<endl;
         L<<Logger::Error<<"Respawning"<<endl;
 
-        goto respawn;
+        sleep(1);
+        continue;
       }
       if(WIFSIGNALED(status)) {
         int sig=WTERMSIG(status);
@@ -324,15 +324,10 @@ static int guardian(int argc, char **argv)
 #endif
 
         L<<Logger::Error<<"Respawning"<<endl;
-        goto respawn;
+        sleep(1);
+        continue;
       }
       L<<Logger::Error<<"No clue what happened! Respawning"<<endl;
-respawn:
-      if (cpid) {
-        L<<Logger::Error<<"Cleaning up any remaining children with PGRP "<<cpid<<endl;
-        kill(-cpid, SIGKILL);
-      }
-      sleep(1);
     }
     else {
       L<<Logger::Error<<"Unable to fork: "<<strerror(errno)<<endl;
@@ -407,19 +402,6 @@ int main(int argc, char **argv)
   versionSetProduct(ProductAuthoritative);
   reportAllTypes(); // init MOADNSParser
 
-  // Even if PDNS is not deamonized it must be
-  // the leader of the process group
-  setpgid(getpid(), 0);
-
-  // Initialize child PID var. It will remain 0 for pdns instance.
-  // It will have child value in the PDNS guardian instance.
-  // cpid is needed to properly terminate PDNS process in
-  // takedown function, and in Guardian's Cycle handler.
-  cpid=0;
-
-  signal(SIGINT, takedown);
-  signal(SIGTERM, takedown);
-
   s_programname="pdns";
   s_starttime=time(0);