]> git.ipfire.org Git - thirdparty/unbound.git/commitdiff
exit on signal, compatible with bad versions of libevent.
authorWouter Wijngaards <wouter@nlnetlabs.nl>
Fri, 2 Mar 2007 09:48:31 +0000 (09:48 +0000)
committerWouter Wijngaards <wouter@nlnetlabs.nl>
Fri, 2 Mar 2007 09:48:31 +0000 (09:48 +0000)
git-svn-id: file:///svn/unbound/trunk@161 be551aaa-1e26-0410-a405-d3ace91eadb9

configure.ac
daemon/daemon.c
daemon/worker.c
doc/Changelog
doc/README

index 5af6e6bed4a0d0231c441af8e3b044fcc37c5125..5961a2c13b4d957aa76072663090fce7c26d9c6b 100644 (file)
@@ -421,6 +421,7 @@ if test x_$withval != x_no; then
        AC_SEARCH_LIBS(event_set, [event])
        AC_CHECK_HEADERS([event.h],,, [AC_INCLUDES_DEFAULT])
        AC_CHECK_FUNCS([event_base_free]) # only in libevent 1.2 and later
+       AC_CHECK_FUNCS([event_base_once]) # only in libevent 1.4? and later
 else
        AC_DEFINE(USE_MINI_EVENT, 1, [Define if you want to use internal select based events])
 fi
@@ -519,6 +520,10 @@ AH_BOTTOM([
 #define fseeko fseek
 #define ftello ftell
 #endif /* HAVE_FSEEKO */
+#if defined(HAVE_EVENT_H) && !defined(HAVE_EVENT_BASE_ONCE) && (defined(HAVE_PTHREAD) || defined(HAVE_SOLARIS_THREADS))
+   /* using version of libevent that is not threadsafe. */
+#  define LIBEVENT_SIGNAL_PROBLEM 1
+#endif
 
 #ifndef RAND_MAX
 #define RAND_MAX       2147483647
index aac6ac6a304b0e913a0ba29bfde1d945d189f4e8..2b32e26afc55f5b5a9b4e7f193048566b4bfc832 100644 (file)
@@ -59,6 +59,9 @@ static int sig_record_reload = 0;
   * when multiple signals in quick succession are sent to us. */
 static RETSIGTYPE record_sigh(int sig)
 {
+#ifdef LIBEVENT_SIGNAL_PROBLEM
+       exit(0);
+#endif 
        switch(sig)
        {
                case SIGTERM:
index cfaf0c9ccdfe889c5f47a9e5aeeda28e017cb9f7..6e68902fb731ad29b24502eae3beb178c63b3e9e 100644 (file)
@@ -323,6 +323,7 @@ worker_init(struct worker* worker, struct config_file *cfg,
                ub_thread_sig_unblock(SIGINT);
                ub_thread_sig_unblock(SIGQUIT);
                ub_thread_sig_unblock(SIGTERM);
+#ifndef LIBEVENT_SIGNAL_PROBLEM
                worker->comsig = comm_signal_create(worker->base, 
                        worker_sighandler, worker);
                if(!worker->comsig || !comm_signal_bind(worker->comsig, SIGHUP)
@@ -333,6 +334,7 @@ worker_init(struct worker* worker, struct config_file *cfg,
                        worker_delete(worker);
                        return 0;
                }
+#endif /* LIBEVENT_SIGNAL_PROBLEM */
        } else { /* !do_sigs */
                worker->comsig = 0;
        }
index fb3caacf3766f0c0ace0c41570b80d7011af0b0a..b9c215125d25ec488b4fcc86d6c8241372f33bb1 100644 (file)
@@ -2,6 +2,9 @@
        - do not compile fork funcs unless needed. Otherwise will give
          type errors as their typedefs have not been enabled.
        - log shows thread numbers much more nicely (and portably).
+       - even on systems with nonthreadsafe libevent signal handling,
+         unbound will exit if given a signal.
+         Reloads will not work, and exit is not graceful.
 
 1 March 2007: Wouter
        - Signals, libevent and threads work well, with libevent patch and
index f701058e75e157f290730039333261a5a471f3ea..c1bb61b83f7457249e834e384f530205d004559a 100644 (file)
@@ -18,4 +18,11 @@ This software is under BSD license, see LICENSE for details.
   * run libtoolize -c if config.sub is missing.
   * autoreconf (autoheader && autoconf), if ./configure is missing.
 
+Known issues
+------------
+o If libevent is older (1.3 and before), unbound will exit instead of reload
+  on sighup. On a restart 'did not exit gracefully last time' warning is 
+  printed. Perform ./configure --with-libevent=no or update libevent, rerun 
+  configure and recompile unbound to make sighup work correctly.
+
 * mailto:wouter@nlnetlabs.nl