From 06bfd7bd2252d24968c3e28d4cf6e44c86b38dbe Mon Sep 17 00:00:00 2001 From: Wouter Wijngaards Date: Sat, 12 Jul 2014 17:34:37 +0000 Subject: [PATCH] - Fix bug in fix for log locks that caused deadlock in signal handler. git-svn-id: file:///svn/unbound/trunk@3182 be551aaa-1e26-0410-a405-d3ace91eadb9 --- daemon/daemon.c | 8 +++++--- daemon/worker.c | 12 +++--------- doc/Changelog | 1 + 3 files changed, 9 insertions(+), 12 deletions(-) diff --git a/daemon/daemon.c b/daemon/daemon.c index fd9d670e0..2c237c55d 100644 --- a/daemon/daemon.c +++ b/daemon/daemon.c @@ -109,8 +109,9 @@ int ub_c_lex_destroy(void); static RETSIGTYPE record_sigh(int sig) { #ifdef LIBEVENT_SIGNAL_PROBLEM - verbose(VERB_OPS, "quit on signal, no cleanup and statistics, " - "because installed libevent version is not threadsafe"); + /* cannot log, verbose here because locks may be held */ + /* quit on signal, no cleanup and statistics, + because installed libevent version is not threadsafe */ exit(0); #endif switch(sig) @@ -135,7 +136,8 @@ static RETSIGTYPE record_sigh(int sig) break; #endif default: - log_err("ignoring signal %d", sig); + /* ignoring signal */ + break; } } diff --git a/daemon/worker.c b/daemon/worker.c index 4611114ea..aede1a68c 100644 --- a/daemon/worker.c +++ b/daemon/worker.c @@ -982,37 +982,31 @@ worker_handle_request(struct comm_point* c, void* arg, int error, void worker_sighandler(int sig, void* arg) { - /* note that log, print, syscalls here give race conditions. */ - /* we still print DETAIL logs, because this is extensive per message - * logging anyway, and the operator may then have an interest - * in the cause for unbound to exit */ + /* note that log, print, syscalls here give race conditions. + * And cause hangups if the log-lock is held by the application. */ struct worker* worker = (struct worker*)arg; switch(sig) { #ifdef SIGHUP case SIGHUP: - verbose(VERB_QUERY, "caught signal SIGHUP"); comm_base_exit(worker->base); break; #endif case SIGINT: - verbose(VERB_QUERY, "caught signal SIGINT"); worker->need_to_exit = 1; comm_base_exit(worker->base); break; #ifdef SIGQUIT case SIGQUIT: - verbose(VERB_QUERY, "caught signal SIGQUIT"); worker->need_to_exit = 1; comm_base_exit(worker->base); break; #endif case SIGTERM: - verbose(VERB_QUERY, "caught signal SIGTERM"); worker->need_to_exit = 1; comm_base_exit(worker->base); break; default: - log_err("unknown signal: %d, ignored", sig); + /* unknown signal, ignored */ break; } } diff --git a/doc/Changelog b/doc/Changelog index e6f7c9e8f..35568118b 100644 --- a/doc/Changelog +++ b/doc/Changelog @@ -2,6 +2,7 @@ - Fix getentropy compat code, function refs were not portable. - Fix to check openssl version number only for OpenSSL. - LibreSSL provides compat items, check for that in configure. + - Fix bug in fix for log locks that caused deadlock in signal handler. 11 July 2014: Matthijs - fake-rfc2553 patch (thanks Benjamin Baier). -- 2.47.2