diff options
Diffstat (limited to 'main')
-rw-r--r-- | main/asterisk.c | 6 | ||||
-rw-r--r-- | main/cdr.c | 2 | ||||
-rw-r--r-- | main/config.c | 106 | ||||
-rw-r--r-- | main/dnsmgr.c | 2 | ||||
-rw-r--r-- | main/dsp.c | 2 | ||||
-rw-r--r-- | main/enum.c | 2 | ||||
-rw-r--r-- | main/features.c | 2 | ||||
-rw-r--r-- | main/http.c | 2 | ||||
-rw-r--r-- | main/loader.c | 4 | ||||
-rw-r--r-- | main/logger.c | 2 | ||||
-rw-r--r-- | main/manager.c | 12 | ||||
-rw-r--r-- | main/rtp.c | 2 | ||||
-rw-r--r-- | main/udptl.c | 5 |
13 files changed, 128 insertions, 21 deletions
diff --git a/main/asterisk.c b/main/asterisk.c index aac00c9b2..ce62850eb 100644 --- a/main/asterisk.c +++ b/main/asterisk.c @@ -2509,11 +2509,11 @@ static void ast_readconfig(void) } found = { 0, 0 }; if (ast_opt_override_config) { - cfg = ast_config_load(ast_config_AST_CONFIG_FILE, config_flags); + cfg = ast_config_load2(ast_config_AST_CONFIG_FILE, "" /* core, can't reload */, config_flags); if (!cfg) ast_log(LOG_WARNING, "Unable to open specified master config file '%s', using built-in defaults\n", ast_config_AST_CONFIG_FILE); } else - cfg = ast_config_load(config, config_flags); + cfg = ast_config_load2(config, "" /* core, can't reload */, config_flags); /* init with buildtime config */ ast_copy_string(cfg_paths.config_dir, DEFAULT_CONFIG_DIR, sizeof(cfg_paths.config_dir)); @@ -2756,7 +2756,7 @@ static void run_startup_commands(void) struct ast_flags cfg_flags = { 0 }; struct ast_variable *v; - if (!(cfg = ast_config_load("cli.conf", cfg_flags))) + if (!(cfg = ast_config_load2("cli.conf", "" /* core, can't reload */, cfg_flags))) return; fd = open("/dev/null", O_RDWR); diff --git a/main/cdr.c b/main/cdr.c index 5b68e8fed..3c45baf85 100644 --- a/main/cdr.c +++ b/main/cdr.c @@ -1330,7 +1330,7 @@ static int do_reload(int reload) int res=0; struct ast_flags config_flags = { reload ? CONFIG_FLAG_FILEUNCHANGED : 0 }; - if ((config = ast_config_load("cdr.conf", config_flags)) == CONFIG_STATUS_FILEUNCHANGED) + if ((config = ast_config_load2("cdr.conf", "cdr", config_flags)) == CONFIG_STATUS_FILEUNCHANGED) return 0; ast_mutex_lock(&cdr_batch_lock); diff --git a/main/config.c b/main/config.c index 0c09cc8eb..29e2e123e 100644 --- a/main/config.c +++ b/main/config.c @@ -1827,7 +1827,7 @@ int read_config_maps(void) configtmp = ast_config_new(); configtmp->max_include_level = 1; - config = ast_config_internal_load(extconfig_conf, configtmp, flags, "", "config.c"); + config = ast_config_internal_load(extconfig_conf, configtmp, flags, "", "extconfig"); if (!config) { ast_config_destroy(configtmp); return 0; @@ -2345,8 +2345,112 @@ static char *handle_cli_core_show_config_mappings(struct ast_cli_entry *e, int c return CLI_SUCCESS; } +static char *handle_cli_config_reload(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) +{ + struct cache_file_mtime *cfmtime; + struct seenlist { + AST_LIST_ENTRY(seenlist) list; + char filename[0]; + } *seenlist; + AST_LIST_HEAD_NOLOCK(, seenlist) seenhead = AST_LIST_HEAD_NOLOCK_INIT_VALUE; + char *completion_value = NULL; + int wordlen, which = 0; + + switch (cmd) { + case CLI_INIT: + e->command = "config reload"; + e->usage = + "Usage: config reload <filename.conf>\n" + " Reloads all modules that reference <filename.conf>\n"; + return NULL; + case CLI_GENERATE: + if (a->pos > 2) { + return NULL; + } + + wordlen = strlen(a->word); + + AST_LIST_LOCK(&cfmtime_head); + AST_LIST_TRAVERSE(&cfmtime_head, cfmtime, list) { + int seen = 0; + AST_LIST_TRAVERSE(&seenhead, seenlist, list) { + if (strcmp(seenlist->filename, cfmtime->filename) == 0) { + seen = 1; + break; + } + } + + if (seen) { + continue; + } + + if (++which > a->n && strncmp(cfmtime->filename, a->word, wordlen) == 0) { + completion_value = ast_strdup(cfmtime->filename); + break; + } + + /* Otherwise save that we've seen this filename */ + if (!(seenlist = ast_malloc(sizeof(*seenlist) + strlen(cfmtime->filename) + 1))) { + break; + } + strcpy(seenlist->filename, cfmtime->filename); + AST_LIST_INSERT_HEAD(&seenhead, seenlist, list); + } + AST_LIST_UNLOCK(&cfmtime_head); + + /* Remove seenlist */ + while ((seenlist = AST_LIST_REMOVE_HEAD(&seenhead, list))) { + ast_free(seenlist); + } + + return completion_value; + } + + if (a->argc != 3) { + return CLI_SHOWUSAGE; + } + + AST_LIST_LOCK(&cfmtime_head); + AST_LIST_TRAVERSE(&cfmtime_head, cfmtime, list) { + if (!strcmp(cfmtime->filename, a->argv[2])) { + char *buf = alloca(strlen("module reload ") + strlen(cfmtime->who_asked) + 1); + sprintf(buf, "module reload %s", cfmtime->who_asked); + ast_cli_command(a->fd, buf); + } + } + AST_LIST_UNLOCK(&cfmtime_head); + + return CLI_SUCCESS; +} + +static char *handle_cli_config_list(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) +{ + struct cache_file_mtime *cfmtime; + + switch (cmd) { + case CLI_INIT: + e->command = "config list"; + e->usage = + "Usage: config list\n" + " Show all modules that have loaded a configuration file\n"; + return NULL; + case CLI_GENERATE: + return NULL; + } + + AST_LIST_LOCK(&cfmtime_head); + AST_LIST_TRAVERSE(&cfmtime_head, cfmtime, list) { + ast_cli(a->fd, "%-20.20s %-50s\n", cfmtime->who_asked, cfmtime->filename); + } + AST_LIST_UNLOCK(&cfmtime_head); + + return CLI_SUCCESS; +} + static struct ast_cli_entry cli_config[] = { AST_CLI_DEFINE(handle_cli_core_show_config_mappings, "Display config mappings (file names to config engines)"), + AST_CLI_DEFINE(handle_cli_config_reload, "Force a reload on modules using a particular configuration file"), + AST_CLI_DEFINE(handle_cli_config_list, "Show all files that have loaded a configuration file"), }; int register_config_cli() diff --git a/main/dnsmgr.c b/main/dnsmgr.c index 0989f6315..a25832850 100644 --- a/main/dnsmgr.c +++ b/main/dnsmgr.c @@ -360,7 +360,7 @@ static int do_reload(int loading) int was_enabled; int res = -1; - if ((config = ast_config_load("dnsmgr.conf", config_flags)) == CONFIG_STATUS_FILEUNCHANGED) + if ((config = ast_config_load2("dnsmgr.conf", "dnsmgr", config_flags)) == CONFIG_STATUS_FILEUNCHANGED) return 0; /* ensure that no refresh cycles run while the reload is in progress */ diff --git a/main/dsp.c b/main/dsp.c index 8e16567a4..3d639a3b6 100644 --- a/main/dsp.c +++ b/main/dsp.c @@ -1548,7 +1548,7 @@ static int _dsp_init(int reload) struct ast_flags config_flags = { reload ? CONFIG_FLAG_FILEUNCHANGED : 0 }; struct ast_config *cfg; - cfg = ast_config_load(CONFIG_FILE_NAME, config_flags); + cfg = ast_config_load2(CONFIG_FILE_NAME, "dsp", config_flags); if (cfg && cfg != CONFIG_STATUS_FILEUNCHANGED) { const char *value; diff --git a/main/enum.c b/main/enum.c index 3f4266ac3..78dafb6ef 100644 --- a/main/enum.c +++ b/main/enum.c @@ -606,7 +606,7 @@ static int private_enum_init(int reload) struct ast_variable *v; struct ast_flags config_flags = { reload ? CONFIG_FLAG_FILEUNCHANGED : 0 }; - if ((cfg = ast_config_load("enum.conf", config_flags)) == CONFIG_STATUS_FILEUNCHANGED) + if ((cfg = ast_config_load2("enum.conf", "enum", config_flags)) == CONFIG_STATUS_FILEUNCHANGED) return 0; /* Destroy existing list */ diff --git a/main/features.c b/main/features.c index 452198540..2c0aab678 100644 --- a/main/features.c +++ b/main/features.c @@ -2594,7 +2594,7 @@ static int load_config(void) atxferdropcall = DEFAULT_ATXFER_DROP_CALL; atxfercallbackretries = DEFAULT_ATXFER_CALLBACK_RETRIES; - cfg = ast_config_load("features.conf", config_flags); + cfg = ast_config_load2("features.conf", "features", config_flags); if (!cfg) { ast_log(LOG_WARNING,"Could not load features.conf\n"); return 0; diff --git a/main/http.c b/main/http.c index 7b11e9c52..9e8735b2c 100644 --- a/main/http.c +++ b/main/http.c @@ -1087,7 +1087,7 @@ static int __ast_http_load(int reload) struct http_uri_redirect *redirect; struct ast_flags config_flags = { reload ? CONFIG_FLAG_FILEUNCHANGED : 0 }; - if ((cfg = ast_config_load("http.conf", config_flags)) == CONFIG_STATUS_FILEUNCHANGED) { + if ((cfg = ast_config_load2("http.conf", "http", config_flags)) == CONFIG_STATUS_FILEUNCHANGED) { return 0; } diff --git a/main/loader.c b/main/loader.c index e05bac4e3..baddec707 100644 --- a/main/loader.c +++ b/main/loader.c @@ -48,6 +48,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$") #include "asterisk/lock.h" #include "asterisk/features.h" #include "asterisk/dsp.h" +#include "asterisk/udptl.h" #ifdef DLFCNCOMPAT #include "asterisk/dlfcn-compat.h" @@ -251,6 +252,7 @@ static struct reload_classes { { "logger", logger_reload }, { "features", ast_features_reload }, { "dsp", ast_dsp_reload}, + { "udptl", ast_udptl_reload }, { NULL, NULL } }; @@ -786,7 +788,7 @@ int load_modules(unsigned int preload_only) embedded_module_list.first = NULL; } - if (!(cfg = ast_config_load(AST_MODULE_CONFIG, config_flags))) { + if (!(cfg = ast_config_load2(AST_MODULE_CONFIG, "" /* core, can't reload */, config_flags))) { ast_log(LOG_WARNING, "No '%s' found, no modules will be loaded.\n", AST_MODULE_CONFIG); goto done; } diff --git a/main/logger.c b/main/logger.c index 072a23bb2..b7c517fa7 100644 --- a/main/logger.c +++ b/main/logger.c @@ -325,7 +325,7 @@ static void init_logger_chain(int reload, int locked) const char *s; struct ast_flags config_flags = { reload ? CONFIG_FLAG_FILEUNCHANGED : 0 }; - if ((cfg = ast_config_load("logger.conf", config_flags)) == CONFIG_STATUS_FILEUNCHANGED) + if ((cfg = ast_config_load2("logger.conf", "logger", config_flags)) == CONFIG_STATUS_FILEUNCHANGED) return; /* delete our list of log channels */ diff --git a/main/manager.c b/main/manager.c index e54238c23..e8eebf9b8 100644 --- a/main/manager.c +++ b/main/manager.c @@ -1089,7 +1089,7 @@ static int action_getconfig(struct mansession *s, const struct message *m) astman_send_error(s, m, "Filename not specified"); return 0; } - if (!(cfg = ast_config_load(fn, config_flags))) { + if (!(cfg = ast_config_load2(fn, "manager", config_flags))) { astman_send_error(s, m, "Config file not found"); return 0; } @@ -1130,7 +1130,7 @@ static int action_listcategories(struct mansession *s, const struct message *m) astman_send_error(s, m, "Filename not specified"); return 0; } - if (!(cfg = ast_config_load(fn, config_flags))) { + if (!(cfg = ast_config_load2(fn, "manager", config_flags))) { astman_send_error(s, m, "Config file not found or file has invalid syntax"); return 0; } @@ -1184,7 +1184,7 @@ static int action_getconfigjson(struct mansession *s, const struct message *m) return 0; } - if (!(cfg = ast_config_load(fn, config_flags))) { + if (!(cfg = ast_config_load2(fn, "manager", config_flags))) { astman_send_error(s, m, "Config file not found"); return 0; } @@ -1355,7 +1355,7 @@ static int action_updateconfig(struct mansession *s, const struct message *m) astman_send_error(s, m, "Filename not specified"); return 0; } - if (!(cfg = ast_config_load(sfn, config_flags))) { + if (!(cfg = ast_config_load2(sfn, "manager", config_flags))) { astman_send_error(s, m, "Config file not found"); return 0; } @@ -3757,7 +3757,7 @@ static int __init_manager(int reload) /* Append placeholder event so master_eventq never runs dry */ append_event("Event: Placeholder\r\n\r\n", 0); } - if ((cfg = ast_config_load("manager.conf", config_flags)) == CONFIG_STATUS_FILEUNCHANGED) + if ((cfg = ast_config_load2("manager.conf", "manager", config_flags)) == CONFIG_STATUS_FILEUNCHANGED) return 0; displayconnects = 1; @@ -3839,7 +3839,7 @@ static int __init_manager(int reload) AST_RWLIST_WRLOCK(&users); /* First, get users from users.conf */ - ucfg = ast_config_load("users.conf", config_flags); + ucfg = ast_config_load2("users.conf", "manager", config_flags); if (ucfg && (ucfg != CONFIG_STATUS_FILEUNCHANGED)) { const char *hasmanager; int genhasmanager = ast_true(ast_variable_retrieve(ucfg, "general", "hasmanager")); diff --git a/main/rtp.c b/main/rtp.c index 1647074de..ff2b83f33 100644 --- a/main/rtp.c +++ b/main/rtp.c @@ -4192,7 +4192,7 @@ static int __ast_rtp_reload(int reload) const char *s; struct ast_flags config_flags = { reload ? CONFIG_FLAG_FILEUNCHANGED : 0 }; - if ((cfg = ast_config_load("rtp.conf", config_flags)) == CONFIG_STATUS_FILEUNCHANGED) + if ((cfg = ast_config_load2("rtp.conf", "rtp", config_flags)) == CONFIG_STATUS_FILEUNCHANGED) return 0; rtpstart = 5000; diff --git a/main/udptl.c b/main/udptl.c index 2f0e1fb97..7dea4d89f 100644 --- a/main/udptl.c +++ b/main/udptl.c @@ -1224,7 +1224,7 @@ static void __ast_udptl_reload(int reload) const char *s; struct ast_flags config_flags = { reload ? CONFIG_FLAG_FILEUNCHANGED : 0 }; - if ((cfg = ast_config_load("udptl.conf", config_flags)) == CONFIG_STATUS_FILEUNCHANGED) + if ((cfg = ast_config_load2("udptl.conf", "udptl", config_flags)) == CONFIG_STATUS_FILEUNCHANGED) return; udptlstart = 4500; @@ -1297,9 +1297,10 @@ static void __ast_udptl_reload(int reload) ast_verb(2, "UDPTL allocating from port range %d -> %d\n", udptlstart, udptlend); } -void ast_udptl_reload(void) +int ast_udptl_reload(void) { __ast_udptl_reload(1); + return 0; } void ast_udptl_init(void) |