exit on signal, compatible with bad versions of libevent.

git-svn-id: file:///svn/unbound/trunk@161 be551aaa-1e26-0410-a405-d3ace91eadb9
This commit is contained in:
Wouter Wijngaards 2007-03-02 09:48:31 +00:00
parent 1c24c78462
commit aa4918c25b
5 changed files with 20 additions and 0 deletions

View 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

View 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:

View 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;
}

View 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

View 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