summaryrefslogtreecommitdiff
path: root/res
diff options
context:
space:
mode:
Diffstat (limited to 'res')
-rw-r--r--res/res_adsi.c3
-rw-r--r--res/res_config_odbc.c5
-rw-r--r--res/res_config_pgsql.c69
-rw-r--r--res/res_config_sqlite.c9
-rw-r--r--res/res_features.c3
-rw-r--r--res/res_indications.c17
-rw-r--r--res/res_jabber.c27
-rw-r--r--res/res_musiconhold.c5
-rw-r--r--res/res_odbc.c8
-rw-r--r--res/res_smdi.c6
-rw-r--r--res/res_snmp.c3
11 files changed, 84 insertions, 71 deletions
diff --git a/res/res_adsi.c b/res/res_adsi.c
index 28ff200e4..21f1d89fa 100644
--- a/res/res_adsi.c
+++ b/res/res_adsi.c
@@ -1067,9 +1067,10 @@ static void adsi_load(void)
int x;
struct ast_config *conf;
struct ast_variable *v;
+ struct ast_flags config_flags = { 0 };
char *name, *sname;
init_state();
- conf = ast_config_load("adsi.conf");
+ conf = ast_config_load("adsi.conf", config_flags);
if (conf) {
x=0;
for (v = ast_variable_browse(conf, "intro"); v; v = v->next) {
diff --git a/res/res_config_odbc.c b/res/res_config_odbc.c
index 5a9ad5cd0..6388ab72b 100644
--- a/res/res_config_odbc.c
+++ b/res/res_config_odbc.c
@@ -486,7 +486,7 @@ static SQLHSTMT config_odbc_prepare(struct odbc_obj *obj, void *data)
return sth;
}
-static struct ast_config *config_odbc(const char *database, const char *table, const char *file, struct ast_config *cfg, int withcomments)
+static struct ast_config *config_odbc(const char *database, const char *table, const char *file, struct ast_config *cfg, struct ast_flags flags)
{
struct ast_variable *new_v;
struct ast_category *cur_cat;
@@ -500,6 +500,7 @@ static struct ast_config *config_odbc(const char *database, const char *table, c
SQLHSTMT stmt;
char last[128] = "";
struct config_odbc_obj q;
+ struct ast_flags loader_flags = { 0 };
memset(&q, 0, sizeof(q));
@@ -542,7 +543,7 @@ static struct ast_config *config_odbc(const char *database, const char *table, c
while ((res = SQLFetch(stmt)) != SQL_NO_DATA) {
if (!strcmp (q.var_name, "#include")) {
- if (!ast_config_internal_load(q.var_val, cfg, 0)) {
+ if (!ast_config_internal_load(q.var_val, cfg, loader_flags)) {
SQLFreeHandle(SQL_HANDLE_STMT, stmt);
ast_odbc_release_obj(obj);
return NULL;
diff --git a/res/res_config_pgsql.c b/res/res_config_pgsql.c
index 2fb0a0e38..c3e9777c2 100644
--- a/res/res_config_pgsql.c
+++ b/res/res_config_pgsql.c
@@ -62,7 +62,7 @@ static char dbsock[MAX_DB_OPTION_SIZE] = "";
static int dbport = 5432;
static time_t connect_time = 0;
-static int parse_config(void);
+static int parse_config(int reload);
static int pgsql_reconnect(const char *database);
static int realtime_pgsql_status(int fd, int argc, char **argv);
@@ -431,7 +431,7 @@ static int update_pgsql(const char *database, const char *table, const char *key
static struct ast_config *config_pgsql(const char *database, const char *table,
const char *file, struct ast_config *cfg,
- int withcomments)
+ struct ast_flags flags)
{
PGresult *result = NULL;
long num_rows;
@@ -496,7 +496,7 @@ static struct ast_config *config_pgsql(const char *database, const char *table,
char *field_var_val = PQgetvalue(result, rowIndex, 2);
char *field_cat_metric = PQgetvalue(result, rowIndex, 3);
if (!strcmp(field_var_name, "#include")) {
- if (!ast_config_internal_load(field_var_val, cfg, 0)) {
+ if (!ast_config_internal_load(field_var_val, cfg, flags)) {
PQclear(result);
ast_mutex_unlock(&pgsql_lock);
return NULL;
@@ -536,35 +536,25 @@ static struct ast_config_engine pgsql_engine = {
static int load_module(void)
{
- if(!parse_config())
+ if(!parse_config(0))
return AST_MODULE_LOAD_DECLINE;
- ast_mutex_lock(&pgsql_lock);
-
- if (!pgsql_reconnect(NULL)) {
- ast_log(LOG_WARNING,
- "Postgresql RealTime: Couldn't establish connection. Check debug.\n");
- ast_debug(1, "Postgresql RealTime: Cannot Connect: %s\n", PQerrorMessage(pgsqlConn));
- }
-
ast_config_engine_register(&pgsql_engine);
ast_verb(1, "Postgresql RealTime driver loaded.\n");
ast_cli_register_multiple(cli_realtime, sizeof(cli_realtime) / sizeof(struct ast_cli_entry));
- ast_mutex_unlock(&pgsql_lock);
-
return 0;
}
static int unload_module(void)
{
- /* Aquire control before doing anything to the module itself. */
+ /* Acquire control before doing anything to the module itself. */
ast_mutex_lock(&pgsql_lock);
if (pgsqlConn) {
PQfinish(pgsqlConn);
pgsqlConn = NULL;
- };
+ }
ast_cli_unregister_multiple(cli_realtime, sizeof(cli_realtime) / sizeof(struct ast_cli_entry));
ast_config_engine_deregister(&pgsql_engine);
ast_verb(1, "Postgresql RealTime unloaded.\n");
@@ -577,40 +567,32 @@ static int unload_module(void)
static int reload(void)
{
- /* Aquire control before doing anything to the module itself. */
- ast_mutex_lock(&pgsql_lock);
-
- if (pgsqlConn) {
- PQfinish(pgsqlConn);
- pgsqlConn = NULL;
- };
- parse_config();
-
- if (!pgsql_reconnect(NULL)) {
- ast_log(LOG_WARNING,
- "Postgresql RealTime: Couldn't establish connection. Check debug.\n");
- ast_debug(1, "Postgresql RealTime: Cannot Connect: %s\n", PQerrorMessage(pgsqlConn));
- }
-
- ast_verb(2, "Postgresql RealTime reloaded.\n");
-
- /* Done reloading. Release lock so others can now use driver. */
- ast_mutex_unlock(&pgsql_lock);
+ parse_config(1);
return 0;
}
-static int parse_config(void)
+static int parse_config(int reload)
{
struct ast_config *config;
const char *s;
+ struct ast_flags config_flags = { reload ? CONFIG_FLAG_FILEUNCHANGED : 0 };
- config = ast_config_load(RES_CONFIG_PGSQL_CONF);
+ if ((config = ast_config_load(RES_CONFIG_PGSQL_CONF, config_flags)) == CONFIG_STATUS_FILEUNCHANGED)
+ return 0;
if (!config) {
- ast_log(LOG_WARNING, "Unable to load config %s\n",RES_CONFIG_PGSQL_CONF);
+ ast_log(LOG_WARNING, "Unable to load config %s\n", RES_CONFIG_PGSQL_CONF);
return 0;
}
+
+ ast_mutex_lock(&pgsql_lock);
+
+ if (pgsqlConn) {
+ PQfinish(pgsqlConn);
+ pgsqlConn = NULL;
+ }
+
if (!(s = ast_variable_retrieve(config, "general", "dbuser"))) {
ast_log(LOG_WARNING,
"Postgresql RealTime: No database user found, using 'asterisk' as default.\n");
@@ -672,6 +654,17 @@ static int parse_config(void)
ast_debug(1, "Postgresql RealTime DBName: %s\n", dbname);
}
+ if (!pgsql_reconnect(NULL)) {
+ ast_log(LOG_WARNING,
+ "Postgresql RealTime: Couldn't establish connection. Check debug.\n");
+ ast_debug(1, "Postgresql RealTime: Cannot Connect: %s\n", PQerrorMessage(pgsqlConn));
+ }
+
+ ast_verb(2, "Postgresql RealTime reloaded.\n");
+
+ /* Done reloading. Release lock so others can now use driver. */
+ ast_mutex_unlock(&pgsql_lock);
+
return 1;
}
diff --git a/res/res_config_sqlite.c b/res/res_config_sqlite.c
index c9c65f881..fd28ef62d 100644
--- a/res/res_config_sqlite.c
+++ b/res/res_config_sqlite.c
@@ -300,14 +300,14 @@ static int add_cfg_entry(void *arg, int argc, char **argv, char **columnNames);
* \param table the table to use
* \param file the file to load from the database
* \param cfg the struct ast_config object to use when storing variables
- * \param withcomments Integer. Flag
+ * \param flags Optional flags. Not used.
* \retval cfg object
* \retval NULL if an error occurred
* \see add_cfg_entry()
*/
static struct ast_config * config_handler(const char *database,
const char *table, const char *file,
- struct ast_config *cfg, int withcomments);
+ struct ast_config *cfg, struct ast_flags flags);
/*!
* \brief Helper function to parse a va_list object into 2 dynamic arrays of
@@ -611,8 +611,9 @@ static int load_config(void)
struct ast_config *config;
struct ast_variable *var;
int error;
+ struct ast_flags config_flags = { 0 };
- config = ast_config_load(RES_SQLITE_CONF_FILE);
+ config = ast_config_load(RES_SQLITE_CONF_FILE, config_flags);
if (!config) {
ast_log(LOG_ERROR, "Unable to load " RES_SQLITE_CONF_FILE "\n");
@@ -725,7 +726,7 @@ static int add_cfg_entry(void *arg, int argc, char **argv, char **columnNames)
}
static struct ast_config *config_handler(const char *database,
- const char *table, const char *file, struct ast_config *cfg, int withcomments)
+ const char *table, const char *file, struct ast_config *cfg, struct ast_flags flags)
{
struct cfg_entry_args args;
char *errormsg;
diff --git a/res/res_features.c b/res/res_features.c
index 70cf1ec81..08cedc071 100644
--- a/res/res_features.c
+++ b/res/res_features.c
@@ -2768,6 +2768,7 @@ static int load_config(void)
struct ast_config *cfg = NULL;
struct ast_variable *var = NULL;
struct feature_group *fg = NULL;
+ struct ast_flags config_flags = { 0 };
char old_parking_ext[AST_MAX_EXTENSION];
char old_parking_con[AST_MAX_EXTENSION] = "";
char *ctg;
@@ -2810,7 +2811,7 @@ static int load_config(void)
atxferdropcall = DEFAULT_ATXFER_DROP_CALL;
atxfercallbackretries = DEFAULT_ATXFER_CALLBACK_RETRIES;
- cfg = ast_config_load("features.conf");
+ cfg = ast_config_load("features.conf", config_flags);
if (!cfg) {
ast_log(LOG_WARNING,"Could not load features.conf\n");
return AST_MODULE_LOAD_DECLINE;
diff --git a/res/res_indications.c b/res/res_indications.c
index 2a4f38a3a..e12b6f9a1 100644
--- a/res/res_indications.c
+++ b/res/res_indications.c
@@ -236,7 +236,7 @@ static int handle_stopplaytones(struct ast_channel *chan, void *data)
}
/*! \brief load indications module */
-static int ind_load_module(void)
+static int ind_load_module(int reload)
{
struct ast_config *cfg;
struct ast_variable *v;
@@ -244,12 +244,18 @@ static int ind_load_module(void)
char *c;
struct ind_tone_zone *tones;
const char *country = NULL;
+ struct ast_flags config_flags = { reload ? CONFIG_FLAG_FILEUNCHANGED : 0 };
/* that the following cast is needed, is yuk! */
/* yup, checked it out. It is NOT written to. */
- cfg = ast_config_load((char *)config);
+ cfg = ast_config_load((char *)config, config_flags);
if (!cfg)
return -1;
+ else if (cfg == CONFIG_STATUS_FILEUNCHANGED)
+ return 0;
+
+ if (reload)
+ ast_unregister_indication_country(NULL);
/* Use existing config to populate the Indication table */
cxt = ast_category_browse(cfg, NULL);
@@ -385,7 +391,7 @@ static int unload_module(void)
/*! \brief Load indications module */
static int load_module(void)
{
- if (ind_load_module())
+ if (ind_load_module(0))
return AST_MODULE_LOAD_DECLINE;
ast_cli_register_multiple(cli_indications, sizeof(cli_indications) / sizeof(struct ast_cli_entry));
ast_register_application("PlayTones", handle_playtones, "Play a tone list", playtones_desc);
@@ -397,10 +403,7 @@ static int load_module(void)
/*! \brief Reload indications module */
static int reload(void)
{
- /* remove the registed indications... */
- ast_unregister_indication_country(NULL);
-
- return ind_load_module();
+ return ind_load_module(1);
}
AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_GLOBAL_SYMBOLS, "Region-specific tones",
diff --git a/res/res_jabber.c b/res/res_jabber.c
index 6653efec5..8410bf2c0 100644
--- a/res/res_jabber.c
+++ b/res/res_jabber.c
@@ -94,8 +94,8 @@ static int aji_test(int fd, int argc, char *argv[]);
static int aji_show_clients(int fd, int argc, char *argv[]);
static int aji_create_client(char *label, struct ast_variable *var, int debug);
static int aji_create_buddy(char *label, struct aji_client *client);
-static int aji_reload(void);
-static int aji_load_config(void);
+static int aji_reload(int reload);
+static int aji_load_config(int reload);
static void aji_pruneregister(struct aji_client *client);
static int aji_filter_roster(void *data, ikspak *pak);
static int aji_get_roster(struct aji_client *client);
@@ -2062,7 +2062,7 @@ static int aji_do_debug(int fd, int argc, char *argv[])
*/
static int aji_do_reload(int fd, int argc, char *argv[])
{
- aji_reload();
+ aji_reload(1);
ast_cli(fd, "Jabber Reloaded.\n");
return RESULT_SUCCESS;
}
@@ -2398,17 +2398,20 @@ static int aji_create_buddy(char *label, struct aji_client *client)
}
/*!< load config file. \return 1. */
-static int aji_load_config(void)
+static int aji_load_config(int reload)
{
char *cat = NULL;
int debug = 1;
struct ast_config *cfg = NULL;
struct ast_variable *var = NULL;
+ struct ast_flags config_flags = { reload ? CONFIG_FLAG_FILEUNCHANGED : 0 };
+
+ if ((cfg = ast_config_load(JABBER_CONFIG, config_flags)) == CONFIG_STATUS_FILEUNCHANGED)
+ return -1;
/* Reset flags to default value */
ast_set_flag(&globalflags, AJI_AUTOPRUNE | AJI_AUTOREGISTER);
- cfg = ast_config_load(JABBER_CONFIG);
if (!cfg) {
ast_log(LOG_WARNING, "No such configuration file %s\n", JABBER_CONFIG);
return 0;
@@ -2508,13 +2511,17 @@ static int manager_jabber_send(struct mansession *s, const struct message *m)
}
/*! \brief Reload the jabber module */
-static int aji_reload()
+static int aji_reload(int reload)
{
+ int res;
+
ASTOBJ_CONTAINER_MARKALL(&clients);
- if (!aji_load_config()) {
+ if (!(res = aji_load_config(reload))) {
ast_log(LOG_ERROR, "JABBER: Failed to load config.\n");
return 0;
- }
+ } else if (res == -1)
+ return 1;
+
ASTOBJ_CONTAINER_PRUNE_MARKED(&clients, aji_client_destroy);
ASTOBJ_CONTAINER_TRAVERSE(&clients, 1, {
ASTOBJ_RDLOCK(iterator);
@@ -2566,7 +2573,7 @@ static int unload_module(void)
static int load_module(void)
{
ASTOBJ_CONTAINER_INIT(&clients);
- if(!aji_reload())
+ if(!aji_reload(0))
return AST_MODULE_LOAD_DECLINE;
ast_manager_register2("JabberSend", EVENT_FLAG_SYSTEM, manager_jabber_send,
"Sends a message to a Jabber Client", mandescr_jabber_send);
@@ -2580,7 +2587,7 @@ static int load_module(void)
/*! \brief Wrapper for aji_reload */
static int reload(void)
{
- aji_reload();
+ aji_reload(1);
return 0;
}
diff --git a/res/res_musiconhold.c b/res/res_musiconhold.c
index 0aa3cc595..9a66b7518 100644
--- a/res/res_musiconhold.c
+++ b/res/res_musiconhold.c
@@ -1013,10 +1013,11 @@ static int load_moh_classes(int reload)
struct mohclass *class;
char *cat;
int numclasses = 0;
+ struct ast_flags config_flags = { reload ? CONFIG_FLAG_FILEUNCHANGED : 0 };
- cfg = ast_config_load("musiconhold.conf");
+ cfg = ast_config_load("musiconhold.conf", config_flags);
- if (!cfg)
+ if (cfg == NULL || cfg == CONFIG_STATUS_FILEUNCHANGED)
return 0;
cat = ast_category_browse(cfg, NULL);
diff --git a/res/res_odbc.c b/res/res_odbc.c
index 6b70f16f6..c9d3ee700 100644
--- a/res/res_odbc.c
+++ b/res/res_odbc.c
@@ -213,10 +213,11 @@ static int load_odbc_config(void)
char *cat, *dsn, *username, *password, *sanitysql;
int enabled, pooling, limit;
int connect = 0, res = 0;
+ struct ast_flags config_flags = { 0 };
struct odbc_class *new;
- config = ast_config_load(cfg);
+ config = ast_config_load(cfg, config_flags);
if (!config) {
ast_log(LOG_WARNING, "Unable to load config file res_odbc.conf\n");
return -1;
@@ -538,6 +539,7 @@ static int reload(void)
char *cat, *dsn, *username, *password, *sanitysql;
int enabled, pooling, limit;
int connect = 0, res = 0;
+ struct ast_flags config_flags = { CONFIG_FLAG_FILEUNCHANGED };
struct odbc_class *new, *class;
struct odbc_obj *current;
@@ -548,8 +550,8 @@ static int reload(void)
class->delme = 1;
}
- config = ast_config_load(cfg);
- if (config) {
+ config = ast_config_load(cfg, config_flags);
+ if (config != NULL && config != CONFIG_STATUS_FILEUNCHANGED) {
for (cat = ast_category_browse(config, NULL); cat; cat=ast_category_browse(config, cat)) {
if (!strcasecmp(cat, "ENV")) {
for (v = ast_variable_browse(config, cat); v; v = v->next) {
diff --git a/res/res_smdi.c b/res/res_smdi.c
index f1f1b193e..01a6404a2 100644
--- a/res/res_smdi.c
+++ b/res/res_smdi.c
@@ -513,6 +513,7 @@ static int smdi_load(int reload)
struct ast_config *conf;
struct ast_variable *v;
struct ast_smdi_interface *iface = NULL;
+ struct ast_flags config_flags = { reload ? CONFIG_FLAG_FILEUNCHANGED : 0 };
int res = 0;
/* Config options */
@@ -524,13 +525,14 @@ static int smdi_load(int reload)
int msdstrip = 0; /* strip zero digits */
long msg_expiry = SMDI_MSG_EXPIRY_TIME;
- if (!(conf = ast_config_load(config_file))) {
+ if (!(conf = ast_config_load(config_file, config_flags))) {
if (reload)
ast_log(LOG_NOTICE, "Unable to reload config %s: SMDI untouched\n", config_file);
else
ast_log(LOG_NOTICE, "Unable to load config %s: SMDI disabled\n", config_file);
return 1;
- }
+ } else if (conf == CONFIG_STATUS_FILEUNCHANGED)
+ return 0;
/* Mark all interfaces that we are listening on. We will unmark them
* as we find them in the config file, this way we know any interfaces
diff --git a/res/res_snmp.c b/res/res_snmp.c
index 05c483ec5..1fac2c31e 100644
--- a/res/res_snmp.c
+++ b/res/res_snmp.c
@@ -48,11 +48,12 @@ static int load_config(void)
{
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;