From: Arran Cudbard-Bell Date: Tue, 30 Dec 2014 03:12:41 +0000 (-0500) Subject: Add event_loop_started global, and remove realms initialized X-Git-Tag: release_3_0_7~394 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1d964c82e2862e88540cfc0eec153f7301e41baf;p=thirdparty%2Ffreeradius-server.git Add event_loop_started global, and remove realms initialized 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 --- diff --git a/src/include/radiusd.h b/src/include/radiusd.h index a0dcb32136b..f54af1e2241 100644 --- a/src/include/radiusd.h +++ b/src/include/radiusd.h @@ -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); diff --git a/src/main/mainconfig.c b/src/main/mainconfig.c index c8dcef8af60..b5ba006b2c4 100644 --- a/src/main/mainconfig.c +++ b/src/main/mainconfig.c @@ -49,9 +49,10 @@ RCSID("$Id$") # include #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; diff --git a/src/main/radiusd.c b/src/main/radiusd.c index c281eb886a5..b8b0a550901 100644 --- a/src/main/radiusd.c +++ b/src/main/radiusd.c @@ -464,6 +464,8 @@ int main(int argc, char *argv[]) exit(EXIT_FAILURE); } + event_loop_started = true; + /* * Start the event loop(s) and threads. */ diff --git a/src/main/realms.c b/src/main/realms.c index b661b28bdb0..9aa0fdfedc6 100644 --- a/src/main/realms.c +++ b/src/main/realms.c @@ -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; }