From 9482db60166d25728a7017f0a382cc8762e30f63 Mon Sep 17 00:00:00 2001 From: Karl Heyes Date: Thu, 24 Jul 2003 23:45:29 +0000 Subject: [PATCH] avoid hitting the mutex's in the signal handler, we could block, which is not something we want to do. Some mutex implementations are signal based. svn path=/trunk/icecast/; revision=5174 --- src/connection.c | 13 ++++++++++++- src/sighandler.c | 15 +++------------ src/sighandler.h | 1 + 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/src/connection.c b/src/connection.c index ad5034ff..d0d2aad8 100644 --- a/src/connection.c +++ b/src/connection.c @@ -41,6 +41,7 @@ #include "logging.h" #include "xslt.h" #include "fserve.h" +#include "sighandler.h" #include "yp.h" #include "source.h" @@ -341,7 +342,17 @@ void connection_accept_loop(void) _build_pool(); - while (global.running == ICE_RUNNING) { + while (global.running == ICE_RUNNING) + { + if (schedule_config_reread) + { + /* reread config file */ + INFO0("Scheduling config reread ..."); + + connection_inject_event(EVENT_CONFIG_READ, NULL); + schedule_config_reread = 0; + } + con = _accept_connection(); if (con) { diff --git a/src/sighandler.c b/src/sighandler.c index 87366577..f12454f4 100644 --- a/src/sighandler.c +++ b/src/sighandler.c @@ -24,6 +24,8 @@ void _sig_hup(int signo); void _sig_die(int signo); #endif +int schedule_config_reread = 0; + void sighandler_initialize(void) { #ifndef _WIN32 @@ -38,18 +40,7 @@ void sighandler_initialize(void) void _sig_hup(int signo) { - /* We do this elsewhere because it's a bad idea to hang around for too - * long re-reading an entire config file inside a signal handler. Bad - * practice. - */ - - INFO1("Caught signal %d, scheduling config reread ...", - signo); - - /* reread config file */ - - connection_inject_event(EVENT_CONFIG_READ, NULL); - + schedule_config_reread = 1; /* some OSes require us to reattach the signal handler */ signal(SIGHUP, _sig_hup); } diff --git a/src/sighandler.h b/src/sighandler.h index e9dd6073..f4f8d682 100644 --- a/src/sighandler.h +++ b/src/sighandler.h @@ -1,6 +1,7 @@ #ifndef __SIGHANDLER_H__ #define __SIGHANDLER_H__ +extern int schedule_config_reread; void sighandler_initialize(void);