From d42646541c0c79473307841a70e6f3823878713e Mon Sep 17 00:00:00 2001 From: Philipp Schafft Date: Sat, 3 Jun 2023 19:30:59 +0000 Subject: [PATCH] Fix: Remove locking from signal handler See also: #2472 --- configure.ac | 1 + src/global.h | 9 ++++++++- src/sighandler.c | 6 +----- src/slave.c | 1 + 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/configure.ac b/configure.ac index f7eeec14..c5932c09 100644 --- a/configure.ac +++ b/configure.ac @@ -147,6 +147,7 @@ AC_TYPE_PID_T AC_TYPE_SIZE_T AC_TYPE_SSIZE_T AC_TYPE_UID_T +AC_CHECK_TYPES([sig_atomic_t], [], [], [[#include ]]) dnl Checks for required libraries diff --git a/src/global.h b/src/global.h index fdad240e..ffb5336b 100644 --- a/src/global.h +++ b/src/global.h @@ -21,6 +21,8 @@ #define ICECAST_VERSION_STRING "Icecast " PACKAGE_VERSION +#include + #include #include "common/thread/thread.h" @@ -37,7 +39,12 @@ typedef struct ice_global_tag time_t sources_update; int sources_legacy; int clients; - int schedule_config_reread; + +#ifdef HAVE_SIG_ATOMIC_T + volatile sig_atomic_t schedule_config_reread; +#else + volatile int schedule_config_reread; +#endif avl_tree *source_tree; /* for locally defined relays */ diff --git a/src/sighandler.c b/src/sighandler.c index 6057e445..dec658a4 100644 --- a/src/sighandler.c +++ b/src/sighandler.c @@ -54,11 +54,7 @@ void _sig_ignore(int signo) void _sig_hup(int signo) { - ICECAST_LOG_INFO("Caught signal %d, scheduling config re-read...", signo); - - global_lock(); - global . schedule_config_reread = 1; - global_unlock(); + global.schedule_config_reread = 1; /* some OSes require us to reattach the signal handler */ signal(SIGHUP, _sig_hup); diff --git a/src/slave.c b/src/slave.c index 593156f4..438f7f31 100644 --- a/src/slave.c +++ b/src/slave.c @@ -883,6 +883,7 @@ static void *_slave_thread(void *arg) /* re-read xml file if requested */ global_lock(); if (global.schedule_config_reread) { + ICECAST_LOG_INFO("Reloading config for reload was queued"); config_reread_config(); global.schedule_config_reread = 0; }