]> git.ipfire.org Git - thirdparty/unbound.git/commitdiff
Fixup for signal handling. No more dangling unbound processes after
authorWouter Wijngaards <wouter@nlnetlabs.nl>
Mon, 12 Nov 2007 11:10:11 +0000 (11:10 +0000)
committerWouter Wijngaards <wouter@nlnetlabs.nl>
Mon, 12 Nov 2007 11:10:11 +0000 (11:10 +0000)
test suite.

git-svn-id: file:///svn/unbound/trunk@739 be551aaa-1e26-0410-a405-d3ace91eadb9

daemon/daemon.c
daemon/worker.c
daemon/worker.h
doc/Changelog
testdata/fwd_compress_c00c.tpkg

index 1ef5f6cd37a5f9c8f64871c61ee08d849064cd20..7a59974eef762fa682c67a74ac611c3241ec8024 100644 (file)
@@ -108,10 +108,10 @@ signal_handling_record()
 static void
 signal_handling_playback(struct worker* wrk)
 {
-       if(sig_record_quit)
-               worker_sighandler(SIGTERM, wrk);
        if(sig_record_reload)
                worker_sighandler(SIGHUP, wrk);
+       if(sig_record_quit)
+               worker_sighandler(SIGTERM, wrk);
        sig_record_quit = 0;
        sig_record_reload = 0;
 }
@@ -425,9 +425,7 @@ daemon_fork(struct daemon* daemon)
        /* we exited! a signal happened! Stop other threads */
        daemon_stop_others(daemon);
 
-       if(daemon->workers[0]->need_to_restart)
-               daemon->need_to_exit = 0;
-       else    daemon->need_to_exit = 1;
+       daemon->need_to_exit = daemon->workers[0]->need_to_exit;
 }
 
 void 
index 64ee700a3cfa115909e8719265b7827c3347e35a..73cd24b70003d5bfe7a46f0643a45edb1be6559b 100644 (file)
@@ -790,22 +790,21 @@ worker_sighandler(int sig, void* arg)
        switch(sig) {
                case SIGHUP:
                        verbose(VERB_DETAIL, "caught signal SIGHUP");
-                       worker->need_to_restart = 1;
                        comm_base_exit(worker->base);
                        break;
                case SIGINT:
                        verbose(VERB_DETAIL, "caught signal SIGINT");
-                       worker->need_to_restart = 0;
+                       worker->need_to_exit = 1;
                        comm_base_exit(worker->base);
                        break;
                case SIGQUIT:
                        verbose(VERB_DETAIL, "caught signal SIGQUIT");
-                       worker->need_to_restart = 0;
+                       worker->need_to_exit = 1;
                        comm_base_exit(worker->base);
                        break;
                case SIGTERM:
                        verbose(VERB_DETAIL, "caught signal SIGTERM");
-                       worker->need_to_restart = 0;
+                       worker->need_to_exit = 1;
                        comm_base_exit(worker->base);
                        break;
                default:
@@ -851,7 +850,7 @@ worker_init(struct worker* worker, struct config_file *cfg,
 {
        unsigned int seed;
        int startport;
-       worker->need_to_restart = 0;
+       worker->need_to_exit = 0;
        worker->base = comm_base_create();
        if(!worker->base) {
                log_err("could not create event handling base");
index 94d1c65e6199d61c3da38c898f2ef908c5a7ff61..2fbdb9e5d7e0b8bb7e3af19809f850d8d5b631e3 100644 (file)
@@ -99,8 +99,8 @@ struct worker {
 
        /** random() table for this worker. */
        struct ub_randstate* rndstate;
-       /** do we need to restart (instead of exit) ? */
-       int need_to_restart;
+       /** do we need to restart or quit (on signal) */
+       int need_to_exit;
        /** allocation cache for this thread */
        struct alloc_cache alloc;
        /** per thread statistics */
index a1676d7dd19da44af1a69a9d1fa609b35ccf65e7..42390527a9ad2d284945f90fe6dce0de98523867 100644 (file)
@@ -1,3 +1,7 @@
+12 November 2007: Wouter
+       - fixup signal handling where SIGTERM could be ignored if a SIGHUP
+         arrives later on.
+
 9 November 2007: Wouter
        - took ldns snapshot in repo.
        - default config file is /etc/unbound/unbound.conf.
index 905bb1b3c0e617f2ac78d8c9561487bdf298f41c..372d25556fc87fd48073220d39137b947dd76065 100644 (file)
Binary files a/testdata/fwd_compress_c00c.tpkg and b/testdata/fwd_compress_c00c.tpkg differ