aboutsummaryrefslogtreecommitdiffstats
path: root/cdr
diff options
context:
space:
mode:
Diffstat (limited to 'cdr')
-rw-r--r--cdr/cdr_adaptive_odbc.c3
-rw-r--r--cdr/cdr_csv.c12
-rw-r--r--cdr/cdr_custom.c6
-rw-r--r--cdr/cdr_manager.c22
-rw-r--r--cdr/cdr_odbc.c195
-rw-r--r--cdr/cdr_pgsql.c66
-rw-r--r--cdr/cdr_radius.c3
-rw-r--r--cdr/cdr_sqlite3_custom.c20
-rw-r--r--cdr/cdr_tds.c85
9 files changed, 210 insertions, 202 deletions
diff --git a/cdr/cdr_adaptive_odbc.c b/cdr/cdr_adaptive_odbc.c
index f97f5ed4f..66f704d68 100644
--- a/cdr/cdr_adaptive_odbc.c
+++ b/cdr/cdr_adaptive_odbc.c
@@ -95,8 +95,9 @@ static int load_config(void)
SQLLEN sqlptr;
int res = 0;
SQLHSTMT stmt = NULL;
+ struct ast_flags config_flags = { 0 }; /* Part of our config comes from the database */
- cfg = ast_config_load(CONFIG);
+ cfg = ast_config_load(CONFIG, config_flags);
if (!cfg) {
ast_log(LOG_WARNING, "Unable to load " CONFIG ". No adaptive ODBC CDRs.\n");
return -1;
diff --git a/cdr/cdr_csv.c b/cdr/cdr_csv.c
index bfc509803..8ae8b3c99 100644
--- a/cdr/cdr_csv.c
+++ b/cdr/cdr_csv.c
@@ -95,22 +95,24 @@ static char *name = "csv";
static FILE *mf = NULL;
-static int load_config(void)
+static int load_config(int reload)
{
struct ast_config *cfg;
struct ast_variable *var;
const char *tmp;
+ struct ast_flags config_flags = { reload ? CONFIG_FLAG_FILEUNCHANGED : 0 };
usegmtime = 0;
loguniqueid = 0;
loguserfield = 0;
- cfg = ast_config_load(config);
+ cfg = ast_config_load(config, config_flags);
if (!cfg) {
ast_log(LOG_WARNING, "unable to load config: %s\n", config);
return 0;
- }
+ } else if (cfg == CONFIG_STATUS_FILEUNCHANGED)
+ return 0;
var = ast_variable_browse(cfg, "csv");
if (!var) {
@@ -316,7 +318,7 @@ static int load_module(void)
{
int res;
- if(!load_config())
+ if(!load_config(0))
return AST_MODULE_LOAD_DECLINE;
res = ast_cdr_register(name, ast_module_info->description, csv_log);
@@ -330,7 +332,7 @@ static int load_module(void)
static int reload(void)
{
- load_config();
+ load_config(1);
return 0;
}
diff --git a/cdr/cdr_custom.c b/cdr/cdr_custom.c
index 80cd47ecf..fa4eb11c4 100644
--- a/cdr/cdr_custom.c
+++ b/cdr/cdr_custom.c
@@ -68,12 +68,16 @@ static int load_config(int reload)
{
struct ast_config *cfg;
struct ast_variable *var;
+ struct ast_flags config_flags = { reload ? CONFIG_FLAG_FILEUNCHANGED : 0 };
int res = -1;
+ if ((cfg = ast_config_load("cdr_custom.conf", config_flags)) == CONFIG_STATUS_FILEUNCHANGED)
+ return 0;
+
strcpy(format, "");
strcpy(master, "");
ast_mutex_lock(&lock);
- if((cfg = ast_config_load("cdr_custom.conf"))) {
+ if (cfg) {
var = ast_variable_browse(cfg, "mappings");
while(var) {
if (!ast_strlen_zero(var->name) && !ast_strlen_zero(var->value)) {
diff --git a/cdr/cdr_manager.c b/cdr/cdr_manager.c
index 5dc4da6fe..028b4a8c9 100644
--- a/cdr/cdr_manager.c
+++ b/cdr/cdr_manager.c
@@ -52,15 +52,22 @@ static char *name = "cdr_manager";
static int enablecdr = 0;
struct ast_str *customfields;
-static int load_config(void)
+static int load_config(int reload)
{
char *cat = NULL;
struct ast_config *cfg;
struct ast_variable *v;
-
+ struct ast_flags config_flags = { reload ? CONFIG_FLAG_FILEUNCHANGED : 0 };
+
+ cfg = ast_config_load(CONF_FILE, config_flags);
+ if (cfg == CONFIG_STATUS_FILEUNCHANGED)
+ return 0;
+
+ if (reload && customfields) {
+ ast_free(customfields);
+ }
customfields = NULL;
- cfg = ast_config_load(CONF_FILE);
if (!cfg) {
/* Standard configuration */
ast_log(LOG_WARNING, "Failed to load configuration file. Module not activated.\n");
@@ -174,7 +181,7 @@ static int load_module(void)
int res;
/* Configuration file */
- if (!load_config())
+ if (!load_config(0))
return AST_MODULE_LOAD_DECLINE;
res = ast_cdr_register(name, "Asterisk Manager Interface CDR Backend", manager_log);
@@ -187,12 +194,7 @@ static int load_module(void)
static int reload(void)
{
- if (customfields) {
- ast_free(customfields);
- }
-
- load_config();
- return 0;
+ return load_config(1);
}
AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT, "Asterisk Manager Interface CDR Backend",
diff --git a/cdr/cdr_odbc.c b/cdr/cdr_odbc.c
index 1ba24f50a..19acbe389 100644
--- a/cdr/cdr_odbc.c
+++ b/cdr/cdr_odbc.c
@@ -226,124 +226,124 @@ static int odbc_unload_module(void)
return 0;
}
-static int odbc_load_module(void)
+static int odbc_load_module(int reload)
{
int res = 0;
struct ast_config *cfg;
struct ast_variable *var;
const char *tmp;
+ struct ast_flags config_flags = { reload ? CONFIG_FLAG_FILEUNCHANGED : 0 };
ast_mutex_lock(&odbc_lock);
- cfg = ast_config_load(config);
- if (!cfg) {
- ast_log(LOG_WARNING, "cdr_odbc: Unable to load config for ODBC CDR's: %s\n", config);
- res = AST_MODULE_LOAD_DECLINE;
- goto out;
- }
+ do {
+ cfg = ast_config_load(config, config_flags);
+ if (!cfg) {
+ ast_log(LOG_WARNING, "cdr_odbc: Unable to load config for ODBC CDR's: %s\n", config);
+ res = AST_MODULE_LOAD_DECLINE;
+ break;
+ } else if (cfg == CONFIG_STATUS_FILEUNCHANGED)
+ break;
- var = ast_variable_browse(cfg, "global");
- if (!var) {
- /* nothing configured */
- goto out;
- }
-
- tmp = ast_variable_retrieve(cfg,"global","dsn");
- if (tmp == NULL) {
- ast_log(LOG_WARNING,"cdr_odbc: dsn not specified. Assuming asteriskdb\n");
- tmp = "asteriskdb";
- }
- dsn = strdup(tmp);
- if (dsn == NULL) {
- ast_log(LOG_ERROR,"cdr_odbc: Out of memory error.\n");
- res = -1;
- goto out;
- }
+ var = ast_variable_browse(cfg, "global");
+ if (!var) {
+ /* nothing configured */
+ break;
+ }
- tmp = ast_variable_retrieve(cfg,"global","dispositionstring");
- if (tmp) {
- dispositionstring = ast_true(tmp);
- } else {
- dispositionstring = 0;
- }
-
- tmp = ast_variable_retrieve(cfg,"global","username");
- if (tmp) {
- username = strdup(tmp);
- if (username == NULL) {
- ast_log(LOG_ERROR,"cdr_odbc: Out of memory error.\n");
+ if ((tmp = ast_variable_retrieve(cfg, "global", "dsn")) == NULL) {
+ ast_log(LOG_WARNING, "cdr_odbc: dsn not specified. Assuming asteriskdb\n");
+ tmp = "asteriskdb";
+ }
+ if (dsn)
+ ast_free(dsn);
+ dsn = ast_strdup(tmp);
+ if (dsn == NULL) {
res = -1;
- goto out;
+ break;
}
- }
- tmp = ast_variable_retrieve(cfg,"global","password");
- if (tmp) {
- password = strdup(tmp);
- if (password == NULL) {
- ast_log(LOG_ERROR,"cdr_odbc: Out of memory error.\n");
- res = -1;
- goto out;
+ if ((tmp = ast_variable_retrieve(cfg, "global", "dispositionstring")))
+ dispositionstring = ast_true(tmp);
+ else
+ dispositionstring = 0;
+
+ if ((tmp = ast_variable_retrieve(cfg, "global", "username"))) {
+ if (username)
+ ast_free(username);
+ username = ast_strdup(tmp);
+ if (username == NULL) {
+ res = -1;
+ break;
+ }
}
- }
- tmp = ast_variable_retrieve(cfg,"global","loguniqueid");
- if (tmp) {
- loguniqueid = ast_true(tmp);
- if (loguniqueid) {
- ast_debug(1,"cdr_odbc: Logging uniqueid\n");
+ if ((tmp = ast_variable_retrieve(cfg, "global", "password"))) {
+ if (password)
+ ast_free(password);
+ password = ast_strdup(tmp);
+ if (password == NULL) {
+ res = -1;
+ break;
+ }
+ }
+
+ if ((tmp = ast_variable_retrieve(cfg, "global", "loguniqueid"))) {
+ loguniqueid = ast_true(tmp);
+ if (loguniqueid) {
+ ast_debug(1, "cdr_odbc: Logging uniqueid\n");
+ } else {
+ ast_debug(1, "cdr_odbc: Not logging uniqueid\n");
+ }
} else {
- ast_debug(1,"cdr_odbc: Not logging uniqueid\n");
+ ast_debug(1, "cdr_odbc: Not logging uniqueid\n");
+ loguniqueid = 0;
}
- } else {
- ast_debug(1,"cdr_odbc: Not logging uniqueid\n");
- loguniqueid = 0;
- }
- tmp = ast_variable_retrieve(cfg,"global","usegmtime");
- if (tmp) {
- usegmtime = ast_true(tmp);
- if (usegmtime) {
- ast_debug(1,"cdr_odbc: Logging in GMT\n");
+ if ((tmp = ast_variable_retrieve(cfg, "global", "usegmtime"))) {
+ usegmtime = ast_true(tmp);
+ if (usegmtime) {
+ ast_debug(1, "cdr_odbc: Logging in GMT\n");
+ } else {
+ ast_debug(1, "cdr_odbc: Not logging in GMT\n");
+ }
} else {
- ast_debug(1,"cdr_odbc: Not logging in GMT\n");
+ ast_debug(1, "cdr_odbc: Not logging in GMT\n");
+ usegmtime = 0;
}
- } else {
- ast_debug(1,"cdr_odbc: Not logging in GMT\n");
- usegmtime = 0;
- }
- tmp = ast_variable_retrieve(cfg,"global","table");
- if (tmp == NULL) {
- ast_log(LOG_WARNING,"cdr_odbc: table not specified. Assuming cdr\n");
- tmp = "cdr";
- }
- table = strdup(tmp);
- if (table == NULL) {
- ast_log(LOG_ERROR,"cdr_odbc: Out of memory error.\n");
- res = -1;
- goto out;
- }
+ if ((tmp = ast_variable_retrieve(cfg, "global", "table")) == NULL) {
+ ast_log(LOG_WARNING, "cdr_odbc: table not specified. Assuming cdr\n");
+ tmp = "cdr";
+ }
+ if (table)
+ ast_free(table);
+ table = ast_strdup(tmp);
+ if (table == NULL) {
+ res = -1;
+ break;
+ }
- ast_verb(3, "cdr_odbc: dsn is %s\n",dsn);
- if (username) {
- ast_verb(3, "cdr_odbc: username is %s\n",username);
- ast_verb(3, "cdr_odbc: password is [secret]\n");
- } else
- ast_verb(3, "cdr_odbc: retreiving username and password from odbc config\n");
- ast_verb(3, "cdr_odbc: table is %s\n",table);
-
- res = odbc_init();
- if (res < 0) {
- ast_log(LOG_ERROR, "cdr_odbc: Unable to connect to datasource: %s\n", dsn);
- ast_verb(3, "cdr_odbc: Unable to connect to datasource: %s\n", dsn);
+ ast_verb(3, "cdr_odbc: dsn is %s\n", dsn);
+ if (username) {
+ ast_verb(3, "cdr_odbc: username is %s\n", username);
+ ast_verb(3, "cdr_odbc: password is [secret]\n");
+ } else
+ ast_verb(3, "cdr_odbc: retrieving username and password from odbc config\n");
+ ast_verb(3, "cdr_odbc: table is %s\n", table);
+
+ res = odbc_init();
+ if (res < 0) {
+ ast_log(LOG_ERROR, "cdr_odbc: Unable to connect to datasource: %s\n", dsn);
+ ast_verb(3, "cdr_odbc: Unable to connect to datasource: %s\n", dsn);
+ }
+ res = ast_cdr_register(name, ast_module_info->description, odbc_log);
+ if (res) {
+ ast_log(LOG_ERROR, "cdr_odbc: Unable to register ODBC CDR handling\n");
}
- res = ast_cdr_register(name, ast_module_info->description, odbc_log);
- if (res) {
- ast_log(LOG_ERROR, "cdr_odbc: Unable to register ODBC CDR handling\n");
- }
-out:
- if (cfg)
+ } while (0);
+
+ if (cfg && cfg != CONFIG_STATUS_FILEUNCHANGED)
ast_config_destroy(cfg);
ast_mutex_unlock(&odbc_lock);
return res;
@@ -418,7 +418,7 @@ static int odbc_init(void)
static int load_module(void)
{
- return odbc_load_module();
+ return odbc_load_module(0);
}
static int unload_module(void)
@@ -428,8 +428,7 @@ static int unload_module(void)
static int reload(void)
{
- odbc_unload_module();
- return odbc_load_module();
+ return odbc_load_module(1);
}
AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT, "ODBC CDR Backend",
diff --git a/cdr/cdr_pgsql.c b/cdr/cdr_pgsql.c
index 4ccd4aa83..d3813c65a 100644
--- a/cdr/cdr_pgsql.c
+++ b/cdr/cdr_pgsql.c
@@ -183,7 +183,7 @@ static int pgsql_log(struct ast_cdr *cdr)
return 0;
}
-static int my_unload_module(void)
+static int unload_module(void)
{
PQfinish(conn);
if (pghostname)
@@ -202,20 +202,30 @@ static int my_unload_module(void)
return 0;
}
-static int process_my_load_module(struct ast_config *cfg)
+static int config_module(int reload)
{
struct ast_variable *var;
- char *pgerror;
+ char *pgerror;
const char *tmp;
+ struct ast_config *cfg;
+ struct ast_flags config_flags = { reload ? CONFIG_FLAG_FILEUNCHANGED : 0 };
+
+ if ((cfg = ast_config_load(config, config_flags)) == NULL) {
+ ast_log(LOG_WARNING, "Unable to load config for PostgreSQL CDR's: %s\n", config);
+ return -1;
+ } else if (cfg == CONFIG_STATUS_FILEUNCHANGED)
+ return 0;
if (!(var = ast_variable_browse(cfg, "global")))
return 0;
- if (!(tmp = ast_variable_retrieve(cfg,"global","hostname"))) {
- ast_log(LOG_WARNING,"PostgreSQL server hostname not specified. Assuming unix socket connection\n");
+ if (!(tmp = ast_variable_retrieve(cfg, "global", "hostname"))) {
+ ast_log(LOG_WARNING, "PostgreSQL server hostname not specified. Assuming unix socket connection\n");
tmp = ""; /* connect via UNIX-socket by default */
}
-
+
+ if (pghostname)
+ ast_free(pghostname);
if (!(pghostname = ast_strdup(tmp)))
return -1;
@@ -224,6 +234,8 @@ static int process_my_load_module(struct ast_config *cfg)
tmp = "asteriskcdrdb";
}
+ if (pgdbname)
+ ast_free(pgdbname);
if (!(pgdbname = ast_strdup(tmp)))
return -1;
@@ -232,6 +244,8 @@ static int process_my_load_module(struct ast_config *cfg)
tmp = "asterisk";
}
+ if (pgdbuser)
+ ast_free(pgdbuser);
if (!(pgdbuser = ast_strdup(tmp)))
return -1;
@@ -240,6 +254,8 @@ static int process_my_load_module(struct ast_config *cfg)
tmp = "";
}
+ if (pgpassword)
+ ast_free(pgpassword);
if (!(pgpassword = ast_strdup(tmp)))
return -1;
@@ -248,6 +264,8 @@ static int process_my_load_module(struct ast_config *cfg)
tmp = "5432";
}
+ if (pgdbport)
+ ast_free(pgdbport);
if (!(pgdbport = ast_strdup(tmp)))
return -1;
@@ -256,6 +274,8 @@ static int process_my_load_module(struct ast_config *cfg)
tmp = "cdr";
}
+ if (table)
+ ast_free(table);
if (!(table = ast_strdup(tmp)))
return -1;
@@ -276,49 +296,23 @@ static int process_my_load_module(struct ast_config *cfg)
ast_debug(1, "Successfully connected to PostgreSQL database.\n");
connected = 1;
} else {
- pgerror = PQerrorMessage(conn);
+ pgerror = PQerrorMessage(conn);
ast_log(LOG_ERROR, "cdr_pgsql: Unable to connect to database server %s. CALLS WILL NOT BE LOGGED!!\n", pghostname);
- ast_log(LOG_ERROR, "cdr_pgsql: Reason: %s\n", pgerror);
+ ast_log(LOG_ERROR, "cdr_pgsql: Reason: %s\n", pgerror);
connected = 0;
}
return ast_cdr_register(name, ast_module_info->description, pgsql_log);
}
-static int my_load_module(void)
-{
- struct ast_config *cfg;
- int res;
-
- if (!(cfg = ast_config_load(config))) {
- ast_log(LOG_WARNING, "Unable to load config for PostgreSQL CDR's: %s\n", config);
- return AST_MODULE_LOAD_DECLINE;
- }
-
- res = process_my_load_module(cfg);
- ast_config_destroy(cfg);
-
- return res;
-}
-
static int load_module(void)
{
- return my_load_module();
-}
-
-static int unload_module(void)
-{
- return my_unload_module();
+ return config_module(0) ? AST_MODULE_LOAD_DECLINE : 0;
}
static int reload(void)
{
- int res;
- ast_mutex_lock(&pgsql_lock);
- my_unload_module();
- res = my_load_module();
- ast_mutex_unlock(&pgsql_lock);
- return res;
+ return config_module(1);
}
AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT, "PostgreSQL CDR Backend",
diff --git a/cdr/cdr_radius.c b/cdr/cdr_radius.c
index b344c0b26..207e24762 100644
--- a/cdr/cdr_radius.c
+++ b/cdr/cdr_radius.c
@@ -232,10 +232,11 @@ static int unload_module(void)
static int load_module(void)
{
struct ast_config *cfg;
+ struct ast_flags config_flags = { 0 };
int res;
const char *tmp;
- if ((cfg = ast_config_load(cdr_config))) {
+ if ((cfg = ast_config_load(cdr_config, config_flags))) {
ast_set2_flag(&global_flags, ast_true(ast_variable_retrieve(cfg, "radius", "usegmtime")), RADIUS_FLAG_USEGMTIME);
ast_set2_flag(&global_flags, ast_true(ast_variable_retrieve(cfg, "radius", "loguniqueid")), RADIUS_FLAG_LOGUNIQUEID);
ast_set2_flag(&global_flags, ast_true(ast_variable_retrieve(cfg, "radius", "loguserfield")), RADIUS_FLAG_LOGUSERFIELD);
diff --git a/cdr/cdr_sqlite3_custom.c b/cdr/cdr_sqlite3_custom.c
index c3dcbd269..1c663362b 100644
--- a/cdr/cdr_sqlite3_custom.c
+++ b/cdr/cdr_sqlite3_custom.c
@@ -74,10 +74,11 @@ static char values[1024];
static int load_config(int reload)
{
struct ast_config *cfg;
+ struct ast_flags config_flags = { reload ? CONFIG_FLAG_FILEUNCHANGED : 0 };
struct ast_variable *mappingvar;
const char *tmp;
- if (!(cfg = ast_config_load(config_file))) {
+ if (!(cfg = ast_config_load(config_file, config_flags))) {
if (reload)
ast_log(LOG_WARNING, "%s: Failed to reload configuration file.\n", name);
else {
@@ -86,10 +87,10 @@ static int load_config(int reload)
name);
}
return -1;
- }
+ } else if (cfg == CONFIG_STATUS_FILEUNCHANGED)
+ return 0;
- if (!reload)
- ast_mutex_lock(&lock);
+ ast_mutex_lock(&lock);
if (!(mappingvar = ast_variable_browse(cfg, "master"))) {
/* nothing configured */
@@ -125,8 +126,7 @@ static int load_config(int reload)
return -1;
}
- if (!reload)
- ast_mutex_unlock(&lock);
+ ast_mutex_unlock(&lock);
ast_config_destroy(cfg);
@@ -248,13 +248,7 @@ static int load_module(void)
static int reload(void)
{
- int res;
-
- ast_mutex_lock(&lock);
- res = load_config(1);
- ast_mutex_unlock(&lock);
-
- return res;
+ return load_config(1);
}
AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT, "SQLite3 Custom CDR Module",
diff --git a/cdr/cdr_tds.c b/cdr/cdr_tds.c
index 2707a4b89..af58b86e6 100644
--- a/cdr/cdr_tds.c
+++ b/cdr/cdr_tds.c
@@ -422,95 +422,106 @@ static int tds_unload_module(void)
return 0;
}
-static int tds_load_module(void)
+static int tds_load_module(int reload)
{
int res = 0;
struct ast_config *cfg;
struct ast_variable *var;
const char *ptr = NULL;
+ struct ast_flags config_flags = { reload ? CONFIG_FLAG_FILEUNCHANGED : 0 };
#ifdef FREETDS_PRE_0_62
TDS_INT result_type;
#endif
- cfg = ast_config_load(config);
+ cfg = ast_config_load(config, config_flags);
if (!cfg) {
ast_log(LOG_NOTICE, "Unable to load config for MSSQL CDR's: %s\n", config);
return 0;
- }
+ } else if (cfg == CONFIG_STATUS_FILEUNCHANGED)
+ return 0;
var = ast_variable_browse(cfg, "global");
if (!var) /* nothing configured */
return 0;
ptr = ast_variable_retrieve(cfg, "global", "hostname");
- if (ptr)
- hostname = strdup(ptr);
- else
- ast_log(LOG_ERROR,"Database server hostname not specified.\n");
+ if (ptr) {
+ if (hostname)
+ ast_free(hostname);
+ hostname = ast_strdup(ptr);
+ } else
+ ast_log(LOG_ERROR, "Database server hostname not specified.\n");
ptr = ast_variable_retrieve(cfg, "global", "dbname");
- if (ptr)
- dbname = strdup(ptr);
- else
- ast_log(LOG_ERROR,"Database dbname not specified.\n");
+ if (ptr) {
+ if (dbname)
+ ast_free(dbname);
+ dbname = ast_strdup(ptr);
+ } else
+ ast_log(LOG_ERROR, "Database dbname not specified.\n");
ptr = ast_variable_retrieve(cfg, "global", "user");
- if (ptr)
- dbuser = strdup(ptr);
- else
- ast_log(LOG_ERROR,"Database dbuser not specified.\n");
+ if (ptr) {
+ if (dbuser)
+ ast_free(dbuser);
+ dbuser = ast_strdup(ptr);
+ } else
+ ast_log(LOG_ERROR, "Database dbuser not specified.\n");
ptr = ast_variable_retrieve(cfg, "global", "password");
- if (ptr)
- password = strdup(ptr);
- else
+ if (ptr) {
+ if (password)
+ ast_free(password);
+ password = ast_strdup(ptr);
+ } else
ast_log(LOG_ERROR,"Database password not specified.\n");
ptr = ast_variable_retrieve(cfg, "global", "charset");
+ if (charset)
+ ast_free(charset);
if (ptr)
- charset = strdup(ptr);
+ charset = ast_strdup(ptr);
else
- charset = strdup("iso_1");
+ charset = ast_strdup("iso_1");
+ if (language)
+ ast_free(language);
ptr = ast_variable_retrieve(cfg, "global", "language");
if (ptr)
- language = strdup(ptr);
+ language = ast_strdup(ptr);
else
- language = strdup("us_english");
+ language = ast_strdup("us_english");
- ptr = ast_variable_retrieve(cfg,"global","table");
+ ptr = ast_variable_retrieve(cfg, "global", "table");
if (ptr == NULL) {
- ast_debug(1,"cdr_tds: table not specified. Assuming cdr\n");
+ ast_debug(1, "cdr_tds: table not specified. Assuming cdr\n");
ptr = "cdr";
}
- table = strdup(ptr);
+ if (table)
+ ast_free(table);
+ table = ast_strdup(ptr);
ast_config_destroy(cfg);
+ ast_mutex_lock(&tds_lock);
+ mssql_disconnect();
mssql_connect();
-
- /* Register MSSQL CDR handler */
- res = ast_cdr_register(name, ast_module_info->description, tds_log);
- if (res)
- {
- ast_log(LOG_ERROR, "Unable to register MSSQL CDR handling\n");
- }
+ ast_mutex_unlock(&tds_lock);
return res;
}
static int reload(void)
{
- tds_unload_module();
- return tds_load_module();
+ return tds_load_module(1);
}
static int load_module(void)
{
- if(!tds_load_module())
+ if (!tds_load_module(0))
return AST_MODULE_LOAD_DECLINE;
- else
- return AST_MODULE_LOAD_SUCCESS;
+ ast_cdr_register(name, ast_module_info->description, tds_log);
+ return AST_MODULE_LOAD_SUCCESS;
}
static int unload_module(void)