[asterisk-commits] [svn-commits] tilghman: trunk r111012 - in /trunk: channels/ include/asterisk/ main/
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Wed Mar 26 13:39:06 CDT 2008
Author: tilghman
Date: Wed Mar 26 13:39:06 2008
New Revision: 111012
URL: http://svn.digium.com/view/asterisk?view=rev&rev=111012
Log:
Add the "config reload <conffile>" command, which allows you to tell Asterisk
to reload any file that references a given configuration file.
Modified:
trunk/channels/iax2-provision.c
trunk/include/asterisk/config.h
trunk/include/asterisk/udptl.h
trunk/main/asterisk.c
trunk/main/cdr.c
trunk/main/config.c
trunk/main/dnsmgr.c
trunk/main/dsp.c
trunk/main/enum.c
trunk/main/features.c
trunk/main/http.c
trunk/main/loader.c
trunk/main/logger.c
trunk/main/manager.c
trunk/main/rtp.c
trunk/main/udptl.c
Modified: trunk/channels/iax2-provision.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/iax2-provision.c?view=diff&rev=111012&r1=111011&r2=111012
==============================================================================
--- trunk/channels/iax2-provision.c (original)
+++ trunk/channels/iax2-provision.c Wed Mar 26 13:39:06 2008
@@ -497,7 +497,7 @@
cur->dead = 1;
cur = cur->next;
}
- cfg = ast_config_load("iaxprov.conf", config_flags);
+ cfg = ast_config_load2("iaxprov.conf", "chan_iax2", config_flags);
if (cfg != NULL && cfg != CONFIG_STATUS_FILEUNCHANGED) {
/* Load as appropriate */
cat = ast_category_browse(cfg, NULL);
Modified: trunk/include/asterisk/config.h
URL: http://svn.digium.com/view/asterisk/trunk/include/asterisk/config.h?view=diff&rev=111012&r1=111011&r2=111012
==============================================================================
--- trunk/include/asterisk/config.h (original)
+++ trunk/include/asterisk/config.h Wed Mar 26 13:39:06 2008
@@ -97,7 +97,7 @@
*/
struct ast_config *ast_config_load2(const char *filename, const char *who_asked, struct ast_flags flags);
-#define ast_config_load(filename, flags) ast_config_load2(filename, __FILE__, flags)
+#define ast_config_load(filename, flags) ast_config_load2(filename, AST_MODULE, flags)
/*! \brief Destroys a config
* \param config pointer to config data structure
Modified: trunk/include/asterisk/udptl.h
URL: http://svn.digium.com/view/asterisk/trunk/include/asterisk/udptl.h?view=diff&rev=111012&r1=111011&r2=111012
==============================================================================
--- trunk/include/asterisk/udptl.h (original)
+++ trunk/include/asterisk/udptl.h Wed Mar 26 13:39:06 2008
@@ -118,7 +118,7 @@
void ast_udptl_init(void);
-void ast_udptl_reload(void);
+int ast_udptl_reload(void);
#if defined(__cplusplus) || defined(c_plusplus)
}
Modified: trunk/main/asterisk.c
URL: http://svn.digium.com/view/asterisk/trunk/main/asterisk.c?view=diff&rev=111012&r1=111011&r2=111012
==============================================================================
--- trunk/main/asterisk.c (original)
+++ trunk/main/asterisk.c Wed Mar 26 13:39:06 2008
@@ -2509,11 +2509,11 @@
} 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 @@
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);
Modified: trunk/main/cdr.c
URL: http://svn.digium.com/view/asterisk/trunk/main/cdr.c?view=diff&rev=111012&r1=111011&r2=111012
==============================================================================
--- trunk/main/cdr.c (original)
+++ trunk/main/cdr.c Wed Mar 26 13:39:06 2008
@@ -1330,7 +1330,7 @@
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);
Modified: trunk/main/config.c
URL: http://svn.digium.com/view/asterisk/trunk/main/config.c?view=diff&rev=111012&r1=111011&r2=111012
==============================================================================
--- trunk/main/config.c (original)
+++ trunk/main/config.c Wed Mar 26 13:39:06 2008
@@ -1827,7 +1827,7 @@
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 @@
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()
Modified: trunk/main/dnsmgr.c
URL: http://svn.digium.com/view/asterisk/trunk/main/dnsmgr.c?view=diff&rev=111012&r1=111011&r2=111012
==============================================================================
--- trunk/main/dnsmgr.c (original)
+++ trunk/main/dnsmgr.c Wed Mar 26 13:39:06 2008
@@ -360,7 +360,7 @@
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 */
Modified: trunk/main/dsp.c
URL: http://svn.digium.com/view/asterisk/trunk/main/dsp.c?view=diff&rev=111012&r1=111011&r2=111012
==============================================================================
--- trunk/main/dsp.c (original)
+++ trunk/main/dsp.c Wed Mar 26 13:39:06 2008
@@ -1548,7 +1548,7 @@
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;
Modified: trunk/main/enum.c
URL: http://svn.digium.com/view/asterisk/trunk/main/enum.c?view=diff&rev=111012&r1=111011&r2=111012
==============================================================================
--- trunk/main/enum.c (original)
+++ trunk/main/enum.c Wed Mar 26 13:39:06 2008
@@ -606,7 +606,7 @@
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 */
Modified: trunk/main/features.c
URL: http://svn.digium.com/view/asterisk/trunk/main/features.c?view=diff&rev=111012&r1=111011&r2=111012
==============================================================================
--- trunk/main/features.c (original)
+++ trunk/main/features.c Wed Mar 26 13:39:06 2008
@@ -2594,7 +2594,7 @@
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;
Modified: trunk/main/http.c
URL: http://svn.digium.com/view/asterisk/trunk/main/http.c?view=diff&rev=111012&r1=111011&r2=111012
==============================================================================
--- trunk/main/http.c (original)
+++ trunk/main/http.c Wed Mar 26 13:39:06 2008
@@ -1087,7 +1087,7 @@
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;
}
Modified: trunk/main/loader.c
URL: http://svn.digium.com/view/asterisk/trunk/main/loader.c?view=diff&rev=111012&r1=111011&r2=111012
==============================================================================
--- trunk/main/loader.c (original)
+++ trunk/main/loader.c Wed Mar 26 13:39:06 2008
@@ -48,6 +48,7 @@
#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 @@
{ "logger", logger_reload },
{ "features", ast_features_reload },
{ "dsp", ast_dsp_reload},
+ { "udptl", ast_udptl_reload },
{ NULL, NULL }
};
@@ -786,7 +788,7 @@
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;
}
Modified: trunk/main/logger.c
URL: http://svn.digium.com/view/asterisk/trunk/main/logger.c?view=diff&rev=111012&r1=111011&r2=111012
==============================================================================
--- trunk/main/logger.c (original)
+++ trunk/main/logger.c Wed Mar 26 13:39:06 2008
@@ -325,7 +325,7 @@
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 */
Modified: trunk/main/manager.c
URL: http://svn.digium.com/view/asterisk/trunk/main/manager.c?view=diff&rev=111012&r1=111011&r2=111012
==============================================================================
--- trunk/main/manager.c (original)
+++ trunk/main/manager.c Wed Mar 26 13:39:06 2008
@@ -1089,7 +1089,7 @@
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 @@
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 @@
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 @@
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 @@
/* 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 @@
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"));
Modified: trunk/main/rtp.c
URL: http://svn.digium.com/view/asterisk/trunk/main/rtp.c?view=diff&rev=111012&r1=111011&r2=111012
==============================================================================
--- trunk/main/rtp.c (original)
+++ trunk/main/rtp.c Wed Mar 26 13:39:06 2008
@@ -4192,7 +4192,7 @@
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;
Modified: trunk/main/udptl.c
URL: http://svn.digium.com/view/asterisk/trunk/main/udptl.c?view=diff&rev=111012&r1=111011&r2=111012
==============================================================================
--- trunk/main/udptl.c (original)
+++ trunk/main/udptl.c Wed Mar 26 13:39:06 2008
@@ -1224,7 +1224,7 @@
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 @@
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)
_______________________________________________
--Bandwidth and Colocation Provided by http://www.api-digital.com--
svn-commits mailing list
To UNSUBSCRIBE or update options visit:
http://lists.digium.com/mailman/listinfo/svn-commits
--
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
More information about the asterisk-commits
mailing list