[asterisk-commits] tilghman: branch tilghman/config_mtime_cache r79745 - in /team/tilghman/confi...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Aug 16 15:52:33 CDT 2007


Author: tilghman
Date: Thu Aug 16 15:52:32 2007
New Revision: 79745

URL: http://svn.digium.com/view/asterisk?view=rev&rev=79745
Log:
And... a few more remaining cases.  Also, remove ast_config_load_with_comments, since it's redundant.

Modified:
    team/tilghman/config_mtime_cache/apps/app_osplookup.c
    team/tilghman/config_mtime_cache/apps/app_voicemail.c
    team/tilghman/config_mtime_cache/cdr/cdr_odbc.c
    team/tilghman/config_mtime_cache/channels/chan_misdn.c
    team/tilghman/config_mtime_cache/channels/chan_vpb.cc
    team/tilghman/config_mtime_cache/channels/misdn/chan_misdn_config.h
    team/tilghman/config_mtime_cache/channels/misdn_config.c
    team/tilghman/config_mtime_cache/codecs/codec_gsm.c
    team/tilghman/config_mtime_cache/codecs/codec_zap.c
    team/tilghman/config_mtime_cache/include/asterisk/config.h
    team/tilghman/config_mtime_cache/main/config.c
    team/tilghman/config_mtime_cache/main/manager.c
    team/tilghman/config_mtime_cache/res/res_snmp.c

Modified: team/tilghman/config_mtime_cache/apps/app_osplookup.c
URL: http://svn.digium.com/view/asterisk/team/tilghman/config_mtime_cache/apps/app_osplookup.c?view=diff&rev=79745&r1=79744&r2=79745
==============================================================================
--- team/tilghman/config_mtime_cache/apps/app_osplookup.c (original)
+++ team/tilghman/config_mtime_cache/apps/app_osplookup.c Thu Aug 16 15:52:32 2007
@@ -1773,15 +1773,22 @@
 
 /* OSP Module APIs */
 
-static int osp_load(void)
+static int osp_unload(void);
+static int osp_load(int reload)
 {
 	const char* t;
 	unsigned int v;
 	struct ast_config* cfg;
+	struct ast_flags config_flags = { reload ? CONFIG_FLAG_FILEUNCHANGED : 0 };
 	int error = OSPC_ERR_NO_ERROR;
 
-	cfg = ast_config_load(OSP_CONFIG_FILE);
+	if ((cfg = ast_config_load(OSP_CONFIG_FILE, config_flags)) == CONFIG_STATUS_FILEUNCHANGED)
+		return 0;
+
 	if (cfg) {
+		if (reload)
+			osp_unload();
+
 		t = ast_variable_retrieve(cfg, OSP_GENERAL_CAT, "accelerate");
 		if (t && ast_true(t)) {
 			if ((error = OSPPInit(1)) != OSPC_ERR_NO_ERROR) {
@@ -2000,7 +2007,7 @@
 {
 	int res;
 
-	if(!osp_load())
+	if (!osp_load(0))
 		return AST_MODULE_LOAD_DECLINE;
 
 	ast_cli_register_multiple(cli_osp, sizeof(cli_osp) / sizeof(struct ast_cli_entry));
@@ -2028,8 +2035,7 @@
 
 static int reload(void)
 {
-	osp_unload();
-	osp_load();
+	osp_load(1);
 
 	return 0;
 }

Modified: team/tilghman/config_mtime_cache/apps/app_voicemail.c
URL: http://svn.digium.com/view/asterisk/team/tilghman/config_mtime_cache/apps/app_voicemail.c?view=diff&rev=79745&r1=79744&r2=79745
==============================================================================
--- team/tilghman/config_mtime_cache/apps/app_voicemail.c (original)
+++ team/tilghman/config_mtime_cache/apps/app_voicemail.c Thu Aug 16 15:52:32 2007
@@ -911,12 +911,13 @@
 	struct ast_category *cat=NULL;
 	char *category=NULL, *value=NULL, *new=NULL;
 	const char *tmp=NULL;
+	struct ast_flags config_flags = { CONFIG_FLAG_WITHCOMMENTS };
 					
 	if (!change_password_realtime(vmu, newpassword))
 		return;
 
 	/* check voicemail.conf */
-	if ((cfg = ast_config_load_with_comments(VOICEMAIL_CONFIG))) {
+	if ((cfg = ast_config_load(VOICEMAIL_CONFIG, config_flags))) {
 		while ((category = ast_category_browse(cfg, category))) {
 			if (!strcasecmp(category, vmu->context)) {
 				if (!(tmp = ast_variable_retrieve(cfg, category, vmu->mailbox))) {
@@ -946,7 +947,7 @@
 	var = NULL;
 	/* check users.conf and update the password stored for the mailbox*/
 	/* if no vmsecret entry exists create one. */
-	if ((cfg = ast_config_load_with_comments("users.conf"))) {
+	if ((cfg = ast_config_load("users.conf", config_flags))) {
 		ast_debug(4, "we are looking for %s\n", vmu->mailbox);
 		while ((category = ast_category_browse(cfg, category))) {
 			ast_debug(4, "users.conf: %s\n", category);

Modified: team/tilghman/config_mtime_cache/cdr/cdr_odbc.c
URL: http://svn.digium.com/view/asterisk/team/tilghman/config_mtime_cache/cdr/cdr_odbc.c?view=diff&rev=79745&r1=79744&r2=79745
==============================================================================
--- team/tilghman/config_mtime_cache/cdr/cdr_odbc.c (original)
+++ team/tilghman/config_mtime_cache/cdr/cdr_odbc.c Thu Aug 16 15:52:32 2007
@@ -343,7 +343,7 @@
 		}
 	} while (0);
 
-	if (cfg)
+	if (cfg && cfg != CONFIG_STATUS_FILEUNCHANGED)
 		ast_config_destroy(cfg);
 	ast_mutex_unlock(&odbc_lock);
 	return res;

Modified: team/tilghman/config_mtime_cache/channels/chan_misdn.c
URL: http://svn.digium.com/view/asterisk/team/tilghman/config_mtime_cache/channels/chan_misdn.c?view=diff&rev=79745&r1=79744&r2=79745
==============================================================================
--- team/tilghman/config_mtime_cache/channels/chan_misdn.c (original)
+++ team/tilghman/config_mtime_cache/channels/chan_misdn.c Thu Aug 16 15:52:32 2007
@@ -4753,7 +4753,7 @@
 		return AST_MODULE_LOAD_DECLINE;
 	}
 	
-	if (misdn_cfg_init(max_ports)) {
+	if (misdn_cfg_init(max_ports, 0)) {
 		ast_log(LOG_ERROR, "Unable to initialize misdn_config.\n");
 		return AST_MODULE_LOAD_DECLINE;
 	}

Modified: team/tilghman/config_mtime_cache/channels/chan_vpb.cc
URL: http://svn.digium.com/view/asterisk/team/tilghman/config_mtime_cache/channels/chan_vpb.cc?view=diff&rev=79745&r1=79744&r2=79745
==============================================================================
--- team/tilghman/config_mtime_cache/channels/chan_vpb.cc (original)
+++ team/tilghman/config_mtime_cache/channels/chan_vpb.cc Thu Aug 16 15:52:32 2007
@@ -2636,7 +2636,7 @@
 }
 
 
-int unload_module()
+static int unload_module()
 {
 	struct vpb_pvt *p;
 	/* First, take us out of the channel loop */
@@ -2701,10 +2701,11 @@
 	return 0;
 }
 
-int load_module()
+static int load_module()
 {
 	struct ast_config *cfg;
 	struct ast_variable *v;
+	struct ast_flags config_flags = { 0 };
 	struct vpb_pvt *tmp;
 	int board = 0, group = 0;
 	ast_group_t	callgroup = 0;
@@ -2721,7 +2722,7 @@
 	int bal3 = -1;
 	char * callerid = NULL;
 
-	cfg = ast_config_load(config);
+	cfg = ast_config_load(config, config_flags);
 
 	/* We *must* have a config file otherwise stop immediately */
 	if (!cfg) {
@@ -2897,29 +2898,10 @@
 	return error;
 }
 
-int usecount()
-{
-	return usecnt;
-}
-
-const char *description()
-{
-	return (char *) desc;
-}
-
-const char *key()
-{
-	return ASTERISK_GPL_KEY;
-}
-
 /**/
 #if defined(__cplusplus) || defined(c_plusplus)
  }
 #endif
 /**/
 
-AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT, "VoiceTronix API driver",
-		.load = load_module,
-		.unload = unload_module,
-		.reload = reload,
-	       );
+AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "VoiceTronix API driver");

Modified: team/tilghman/config_mtime_cache/channels/misdn/chan_misdn_config.h
URL: http://svn.digium.com/view/asterisk/team/tilghman/config_mtime_cache/channels/misdn/chan_misdn_config.h?view=diff&rev=79745&r1=79744&r2=79745
==============================================================================
--- team/tilghman/config_mtime_cache/channels/misdn/chan_misdn_config.h (original)
+++ team/tilghman/config_mtime_cache/channels/misdn/chan_misdn_config.h Thu Aug 16 15:52:32 2007
@@ -108,7 +108,7 @@
 };
 
 /* you must call misdn_cfg_init before any other function of this header file */
-int misdn_cfg_init(int max_ports); 
+int misdn_cfg_init(int max_ports, int reload); 
 void misdn_cfg_reload(void);
 void misdn_cfg_destroy(void);
 

Modified: team/tilghman/config_mtime_cache/channels/misdn_config.c
URL: http://svn.digium.com/view/asterisk/team/tilghman/config_mtime_cache/channels/misdn_config.c?view=diff&rev=79745&r1=79744&r2=79745
==============================================================================
--- team/tilghman/config_mtime_cache/channels/misdn_config.c (original)
+++ team/tilghman/config_mtime_cache/channels/misdn_config.c Thu Aug 16 15:52:32 2007
@@ -1063,7 +1063,7 @@
 
 void misdn_cfg_reload (void)
 {
-	misdn_cfg_init (0);
+	misdn_cfg_init(0, 1);
 }
 
 void misdn_cfg_destroy (void)
@@ -1082,18 +1082,20 @@
 	ast_mutex_destroy(&config_mutex);
 }
 
-int misdn_cfg_init (int this_max_ports)
+int misdn_cfg_init(int this_max_ports, int reload)
 {
 	char config[] = "misdn.conf";
 	char *cat, *p;
 	int i;
 	struct ast_config *cfg;
 	struct ast_variable *v;
-
-	if (!(cfg = AST_LOAD_CFG(config))) {
+	struct ast_flags config_flags = { reload ? CONFIG_FLAG_FILEUNCHANGED : 0 };
+
+	if (!(cfg = AST_LOAD_CFG(config, config_flags))) {
 		ast_log(LOG_WARNING, "missing file: misdn.conf\n");
 		return -1;
-	}
+	} else if (cfg == CONFIG_STATUS_FILEUNCHANGED)
+		return 0;
 
 	ast_mutex_init(&config_mutex);
 

Modified: team/tilghman/config_mtime_cache/codecs/codec_gsm.c
URL: http://svn.digium.com/view/asterisk/team/tilghman/config_mtime_cache/codecs/codec_gsm.c?view=diff&rev=79745&r1=79744&r2=79745
==============================================================================
--- team/tilghman/config_mtime_cache/codecs/codec_gsm.c (original)
+++ team/tilghman/config_mtime_cache/codecs/codec_gsm.c Thu Aug 16 15:52:32 2007
@@ -240,7 +240,7 @@
 	struct ast_variable *var;
 	struct ast_flags config_flags = { reload ? CONFIG_FLAG_FILEUNCHANGED : 0 };
 	struct ast_config *cfg = ast_config_load("codecs.conf", config_flags);
-	if (!cfg)
+	if (!cfg || cfg == CONFIG_STATUS_FILEUNCHANGED)
 		return;
 	for (var = ast_variable_browse(cfg, "plc"); var; var = var->next) {
 	       if (!strcasecmp(var->name, "genericplc")) {

Modified: team/tilghman/config_mtime_cache/codecs/codec_zap.c
URL: http://svn.digium.com/view/asterisk/team/tilghman/config_mtime_cache/codecs/codec_zap.c?view=diff&rev=79745&r1=79744&r2=79745
==============================================================================
--- team/tilghman/config_mtime_cache/codecs/codec_zap.c (original)
+++ team/tilghman/config_mtime_cache/codecs/codec_zap.c Thu Aug 16 15:52:32 2007
@@ -312,12 +312,13 @@
 	AST_LIST_UNLOCK(&translators);
 }
 
-static void parse_config(void)
+static void parse_config(int reload)
 {
 	struct ast_variable *var;
-	struct ast_config *cfg = ast_config_load("codecs.conf");
-
-	if (!cfg)
+	struct ast_flags config_flags = { reload ? CONFIG_FLAG_FILEUNCHANGED : 0 };
+	struct ast_config *cfg = ast_config_load("codecs.conf", config_flags);
+
+	if (!cfg || cfg == CONFIG_STATUS_FILEUNCHANGED)
 		return;
 
 	for (var = ast_variable_browse(cfg, "plc"); var; var = var->next) {
@@ -387,7 +388,7 @@
 {
 	struct translator *cur;
 
-	parse_config();
+	parse_config(1);
 
 	AST_LIST_LOCK(&translators);
 	AST_LIST_TRAVERSE(&translators, cur, entry)
@@ -406,7 +407,7 @@
 
 static int load_module(void)
 {
-	parse_config();
+	parse_config(0);
 	find_transcoders();
 
 	return 0;

Modified: team/tilghman/config_mtime_cache/include/asterisk/config.h
URL: http://svn.digium.com/view/asterisk/team/tilghman/config_mtime_cache/include/asterisk/config.h?view=diff&rev=79745&r1=79744&r2=79745
==============================================================================
--- team/tilghman/config_mtime_cache/include/asterisk/config.h (original)
+++ team/tilghman/config_mtime_cache/include/asterisk/config.h Thu Aug 16 15:52:32 2007
@@ -34,7 +34,7 @@
 
 struct ast_category;
 
-/*! Options for config_file_load
+/*! Options for ast_config_load()
  */
 enum {
 	/*! Load the configuration, including comments */
@@ -83,12 +83,15 @@
 /*! \brief Load a config file 
  * \param filename path of file to open.  If no preceding '/' character, path is considered relative to AST_CONFIG_DIR
  * Create a config structure from a given configuration file.
+ * \param flags Optional flags:
+ * CONFIG_FLAG_WITHCOMMENTS - load the file with comments intact;
+ * CONFIG_FLAG_FILEUNCHANGED - check the file mtime and return CONFIG_STATUS_FILEUNCHANGED if the mtime is the same; or
+ * CONFIG_FLAG_NOCACHE - don't cache file mtime (main purpose of this option is to save memory on temporary files).
  *
  * \retval an ast_config data structure on success
  * \retval NULL on error
  */
 struct ast_config *ast_config_load(const char *filename, struct ast_flags flags);
-struct ast_config *ast_config_load_with_comments(const char *filename);
 
 /*! \brief Destroys a config 
  * \param config pointer to config data structure

Modified: team/tilghman/config_mtime_cache/main/config.c
URL: http://svn.digium.com/view/asterisk/team/tilghman/config_mtime_cache/main/config.c?view=diff&rev=79745&r1=79744&r2=79745
==============================================================================
--- team/tilghman/config_mtime_cache/main/config.c (original)
+++ team/tilghman/config_mtime_cache/main/config.c Thu Aug 16 15:52:32 2007
@@ -1434,23 +1434,6 @@
 	return result;
 }
 
-struct ast_config *ast_config_load_with_comments(const char *filename)
-{
-	struct ast_config *cfg;
-	struct ast_config *result;
-	struct ast_flags flags = { CONFIG_FLAG_WITHCOMMENTS };
-
-	cfg = ast_config_new();
-	if (!cfg)
-		return NULL;
-
-	result = ast_config_internal_load(filename, cfg, flags);
-	if (!result || result == CONFIG_STATUS_FILEUNCHANGED)
-		ast_config_destroy(cfg);
-
-	return result;
-}
-
 static struct ast_variable *ast_load_realtime_helper(const char *family, va_list ap)
 {
 	struct ast_config_engine *eng;

Modified: team/tilghman/config_mtime_cache/main/manager.c
URL: http://svn.digium.com/view/asterisk/team/tilghman/config_mtime_cache/main/manager.c?view=diff&rev=79745&r1=79744&r2=79745
==============================================================================
--- team/tilghman/config_mtime_cache/main/manager.c (original)
+++ team/tilghman/config_mtime_cache/main/manager.c Thu Aug 16 15:52:32 2007
@@ -1118,12 +1118,13 @@
 	int lineno = 0;
 	char *category=NULL;
 	struct ast_variable *v;
+	struct ast_flags config_flags = { CONFIG_FLAG_WITHCOMMENTS | CONFIG_FLAG_NOCACHE };
 
 	if (ast_strlen_zero(fn)) {
 		astman_send_error(s, m, "Filename not specified");
 		return 0;
 	}
-	if (!(cfg = ast_config_load_with_comments(fn))) {
+	if (!(cfg = ast_config_load(fn, config_flags))) {
 		astman_send_error(s, m, "Config file not found");
 		return 0;
 	}
@@ -1168,13 +1169,14 @@
 	int comma1 = 0;
 	char *buf = NULL;
 	unsigned int buf_len = 0;
+	struct ast_flags config_flags = { CONFIG_FLAG_WITHCOMMENTS | CONFIG_FLAG_NOCACHE };
 
 	if (ast_strlen_zero(fn)) {
 		astman_send_error(s, m, "Filename not specified");
 		return 0;
 	}
 
-	if (!(cfg = ast_config_load_with_comments(fn))) {
+	if (!(cfg = ast_config_load(fn, config_flags))) {
 		astman_send_error(s, m, "Config file not found");
 		return 0;
 	}
@@ -1303,12 +1305,13 @@
 	const char *dfn = astman_get_header(m, "DstFilename");
 	int res;
 	const char *rld = astman_get_header(m, "Reload");
+	struct ast_flags config_flags = { CONFIG_FLAG_WITHCOMMENTS | CONFIG_FLAG_NOCACHE };
 
 	if (ast_strlen_zero(sfn) || ast_strlen_zero(dfn)) {
 		astman_send_error(s, m, "Filename not specified");
 		return 0;
 	}
-	if (!(cfg = ast_config_load_with_comments(sfn))) {
+	if (!(cfg = ast_config_load(sfn, config_flags))) {
 		astman_send_error(s, m, "Config file not found");
 		return 0;
 	}

Modified: team/tilghman/config_mtime_cache/res/res_snmp.c
URL: http://svn.digium.com/view/asterisk/team/tilghman/config_mtime_cache/res/res_snmp.c?view=diff&rev=79745&r1=79744&r2=79745
==============================================================================
--- team/tilghman/config_mtime_cache/res/res_snmp.c (original)
+++ team/tilghman/config_mtime_cache/res/res_snmp.c Thu Aug 16 15:52:32 2007
@@ -48,11 +48,12 @@
 {
 	struct ast_variable *var;
 	struct ast_config *cfg;
+	struct ast_flags config_flags = { 0 };
 	char *cat;
 
 	res_snmp_enabled = 0;
 	res_snmp_agentx_subagent = 1;
-	cfg = ast_config_load("res_snmp.conf");
+	cfg = ast_config_load("res_snmp.conf", config_flags);
 	if (!cfg) {
 		ast_log(LOG_WARNING, "Could not load res_snmp.conf\n");
 		return 0;




More information about the asterisk-commits mailing list