From: Alan T. DeKok Date: Wed, 2 Sep 2015 17:34:22 +0000 (-0400) Subject: Don't us be HUP'd repeatedly. X-Git-Tag: release_3_0_10~176 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b8421fc2a1a530eef33983bd3fb3b8d7529aef53;p=thirdparty%2Ffreeradius-server.git Don't us be HUP'd repeatedly. It should only be HUP'd every few seconds --- diff --git a/src/include/modpriv.h b/src/include/modpriv.h index b183830f9b9..fc8ec5aae36 100644 --- a/src/include/modpriv.h +++ b/src/include/modpriv.h @@ -49,6 +49,7 @@ typedef struct module_instance_t { pthread_mutex_t *mutex; #endif CONF_SECTION *cs; + time_t last_hup; bool instantiated; bool force; rlm_rcode_t code; diff --git a/src/main/mainconfig.c b/src/main/mainconfig.c index 8b5e889283d..fd6881d70a1 100644 --- a/src/main/mainconfig.c +++ b/src/main/mainconfig.c @@ -1086,8 +1086,11 @@ void main_config_hup(void) int rcode; cached_config_t *cc; CONF_SECTION *cs; + time_t when; char buffer[1024]; + static time_t last_hup = 0; + /* * Re-open the log file. If we can't, then keep logging * to the old log file. @@ -1097,6 +1100,16 @@ void main_config_hup(void) */ hup_logfile(); + /* + * Only check the config files every few seconds. + */ + when = time(NULL); + if ((last_hup + 2) >= when) { + INFO("HUP - Last HUP was too recent. Ignoring"); + return; + } + last_hup = when; + rcode = cf_file_changed(cs_cache->cs); if (rcode == CF_FILE_NONE) { INFO("HUP - No files changed. Ignoring"); diff --git a/src/main/modules.c b/src/main/modules.c index 476a12bff35..58bf4130d6e 100644 --- a/src/main/modules.c +++ b/src/main/modules.c @@ -761,6 +761,7 @@ module_instance_t *module_instantiate(CONF_SECTION *modules, char const *askedna #endif node->instantiated = true; + node->last_hup = time(NULL); /* don't let us load it, then immediately hup it */ return node; } @@ -1518,6 +1519,12 @@ int module_hup_module(CONF_SECTION *cs, module_instance_t *node, time_t when) return 1; } + /* + * Silently ignore multiple HUPs within a short time period. + */ + if ((node->last_hup + 2) >= when) return 1; + node->last_hup = when; + cf_log_module(cs, "Trying to reload module \"%s\"", node->name); /*