From: Adam Dickmeiss Date: Fri, 14 Feb 2014 19:01:34 +0000 (+0100) Subject: Avoid yaz_log calls in signal handlers MP-513 X-Git-Tag: v1.4.4~2 X-Git-Url: http://jsfdemo.indexdata.com/cgi-bin?a=commitdiff_plain;h=15e63ff49000e082d8387c243941485ccacff13b;p=metaproxy-moved-to-github.git Avoid yaz_log calls in signal handlers MP-513 --- diff --git a/src/metaproxy_prog.cpp b/src/metaproxy_prog.cpp index 438f19f..58629d3 100644 --- a/src/metaproxy_prog.cpp +++ b/src/metaproxy_prog.cpp @@ -58,19 +58,20 @@ static void set_log_prefix(void) #if HAVE_UNISTD_H static pid_t process_group = 0; +static int sig_received = 0; static void sig_usr1_handler(int signo) { - yaz_log(YLOG_LOG, "metaproxy received SIGUSR1"); + sig_received = signo; if (routerp) routerp->stop(signo); } static void sig_term_handler(int signo) { + sig_received = signo; if (routerp) { - yaz_log(YLOG_LOG, "metaproxy received SIGTERM"); routerp->stop(signo); } } @@ -90,6 +91,21 @@ static void work_common(void *data) mp::Package pack; pack.router(*routerp).move(); +#if HAVE_UNISTD_H + switch (sig_received) + { + case SIGTERM: + yaz_log(YLOG_LOG, "metaproxy received SIGTERM"); + break; + case SIGUSR1: + yaz_log(YLOG_LOG, "metaproxy received SIGUSR1"); + break; + case 0: + break; + default: + yaz_log(YLOG_LOG, "metaproxy received signo=%d", sig_received); + } +#endif yaz_log(YLOG_LOG, "metaproxy stop"); delete routerp; routerp = 0;