]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Add event_loop_started global, and remove realms initialized
authorArran Cudbard-Bell <a.cudbardb@freeradius.org>
Tue, 30 Dec 2014 03:12:41 +0000 (22:12 -0500)
committerArran Cudbard-Bell <a.cudbardb@freeradius.org>
Tue, 30 Dec 2014 21:19:52 +0000 (16:19 -0500)
It's fine for modules to add additional home servers or realms when dynamic mode isn't enabled as long as the workers haven't started processing requests

src/include/radiusd.h
src/main/mainconfig.c
src/main/radiusd.c
src/main/realms.c

index a0dcb32136b9274c9393548d5c0688938e8535a1..f54af1e224102e964a5e16a589dcdc1fb2c5a548 100644 (file)
@@ -722,9 +722,10 @@ void       thread_pool_queue_stats(int array[RAD_LISTEN_MAX], int pps[2]);
 
 /* main_config.c */
 /* Define a global config structure */
-extern bool log_dates_utc;
-extern bool check_config;
-extern struct main_config_t main_config;
+extern bool                    log_dates_utc;
+extern bool                    check_config;
+extern struct main_config_t    main_config;
+extern bool                    event_loop_started;
 
 void set_radius_dir(TALLOC_CTX *ctx, char const *path);
 char const *get_radius_dir(void);
index c8dcef8af608618da337e88e474cfb8c0aa568ea..b5ba006b2c47e0357d94f7fe0c00ac43cad6f1a4 100644 (file)
@@ -49,9 +49,10 @@ RCSID("$Id$")
 #  include <fcntl.h>
 #endif
 
-struct main_config_t main_config;
-extern fr_cond_t *debug_condition;
-fr_cond_t *debug_condition;
+struct main_config_t   main_config;                            //!< Main server configuration.
+extern fr_cond_t       *debug_condition;
+fr_cond_t              *debug_condition;                       //!< Condition used to mark packets up for checking.
+bool                   event_loop_started = false;             //!< Whether the main event loop has been started yet.
 
 typedef struct cached_config_t {
        struct cached_config_t *next;
index c281eb886a5b551824cca59aac3d0609de402f1e..b8b0a550901ff0eaa2e74c89711842e213b9c38a 100644 (file)
@@ -464,6 +464,8 @@ int main(int argc, char *argv[])
                exit(EXIT_FAILURE);
        }
 
+       event_loop_started = true;
+
        /*
         *  Start the event loop(s) and threads.
         */
index b661b28bdb037f7e69c32a52a4bc26fe2739006c..9aa0fdfedc6aa80312b6b0a237a8a49ef5c01875 100644 (file)
@@ -84,7 +84,6 @@ static const FR_NAME_NUMBER home_proto[] = {
 
 
 static realm_config_t *realm_config = NULL;
-static bool realms_initialized = false;
 
 #ifdef WITH_PROXY
 static rbtree_t        *home_servers_byaddr = NULL;
@@ -559,14 +558,6 @@ home_server_t *home_server_afrom_cs(TALLOC_CTX *ctx, realm_config_t *rc, CONF_SE
 
        CONF_SECTION    *tls;
 
-       /*
-        *      The structs aren't mutex protected.  Refuse to destroy
-        *      the server.
-        */
-       if (realms_initialized && !realm_config->dynamic) {
-               ERROR("Failed to add dynamic home server, \"dynamic = true\" must be set in proxy.conf");
-               return false;
-       }
        if (!rc) rc = realm_config; /* Use the global config */
 
        home = talloc_zero(ctx, home_server_t);
@@ -895,7 +886,7 @@ static int pool_check_home_server(UNUSED realm_config_t *rc, CONF_PAIR *cp,
 #ifndef HAVE_PTHREAD_H
 void realm_pool_free(home_pool_t *pool)
 {
-       if (!realms_initialized) return;
+       if (!event_loop_started) return;
        if (!realm_config->dynamic) return;
 
        talloc_free(pool);
@@ -919,7 +910,7 @@ void realm_pool_free(home_pool_t *pool)
        time_t now;
        pool_list_t *this, **last;
 
-       if (!realms_initialized) return;
+       if (!event_loop_started) return;
        if (!realm_config->dynamic) return;
 
        if (pool) {
@@ -1000,7 +991,7 @@ int realm_pool_add(home_pool_t *pool, UNUSED CONF_SECTION *cs)
         *      The structs aren't mutex protected.  Refuse to destroy
         *      the server.
         */
-       if (realms_initialized && !realm_config->dynamic) {
+       if (event_loop_started && !realm_config->dynamic) {
                DEBUG("Must set \"dynamic = true\" in proxy.conf");
                return 0;
        }
@@ -1836,7 +1827,7 @@ int realm_realm_add(REALM *r, UNUSED CONF_SECTION *cs)
         *      The structs aren't mutex protected.  Refuse to destroy
         *      the server.
         */
-       if (realms_initialized && !realm_config->dynamic) {
+       if (event_loop_started && !realm_config->dynamic) {
                DEBUG("Must set \"dynamic = true\" in proxy.conf");
                return 0;
        }
@@ -1949,7 +1940,7 @@ int realms_init(CONF_SECTION *config)
 #endif
        realm_config_t *rc;
 
-       if (realms_initialized) return 1;
+       if (event_loop_started) return 1;
 
        rc = talloc_zero(NULL, realm_config_t);
        rc->cs = config;
@@ -2065,7 +2056,6 @@ int realms_init(CONF_SECTION *config)
 #endif
 
        realm_config = rc;
-       realms_initialized = true;
        return 1;
 }