]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Don't us be HUP'd repeatedly.
authorAlan T. DeKok <aland@freeradius.org>
Wed, 2 Sep 2015 17:34:22 +0000 (13:34 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Wed, 2 Sep 2015 17:37:39 +0000 (13:37 -0400)
It should only be HUP'd every few seconds

src/include/modpriv.h
src/main/mainconfig.c
src/main/modules.c

index b183830f9b9374ad13000e240b61033fc7a6daf1..fc8ec5aae362a39933f31ab75bcfdbbd08d10826 100644 (file)
@@ -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;
index 8b5e889283db163df7780a0d016cb61c714a862a..fd6881d70a10389080791c5f5640c70559e1ad05 100644 (file)
@@ -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");
index 476a12bff3571d0e98a5f91a7184bbb41065b2a4..58bf4130d6e85932fc8425f96cc726368976bc99 100644 (file)
@@ -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);
 
        /*