mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-04-22 11:19:52 +00:00
FS-2973 Fix possible segfaults and memory leak during unload, and add new setting odbc-retries
This commit is contained in:
parent
1c95ad98cd
commit
7fbc47f83a
@ -11,6 +11,9 @@
|
|||||||
<!-- IP or Hostname of Default Route -->
|
<!-- IP or Hostname of Default Route -->
|
||||||
<param name="default-gateway" value="192.168.66.6"/>
|
<param name="default-gateway" value="192.168.66.6"/>
|
||||||
|
|
||||||
|
<!-- Number of times to retry ODBC connection on connection problems, default is 120 -->
|
||||||
|
<param name="odbc-retries" value="120"/>
|
||||||
|
|
||||||
<!-- Customer Query. Use this with Care!!! We are not responsible if you mess
|
<!-- Customer Query. Use this with Care!!! We are not responsible if you mess
|
||||||
This up!!! Query *MUST* return columns in the following order!
|
This up!!! Query *MUST* return columns in the following order!
|
||||||
gateway varchar(128) - contains destination gateway host:port pair (ex: 192.168.1.1:5060 )
|
gateway varchar(128) - contains destination gateway host:port pair (ex: 192.168.1.1:5060 )
|
||||||
|
@ -65,6 +65,7 @@ static struct {
|
|||||||
switch_mutex_t *mutex;
|
switch_mutex_t *mutex;
|
||||||
char *custom_query;
|
char *custom_query;
|
||||||
switch_odbc_handle_t *master_odbc;
|
switch_odbc_handle_t *master_odbc;
|
||||||
|
int odbc_num_retries;
|
||||||
} globals;
|
} globals;
|
||||||
|
|
||||||
SWITCH_MODULE_LOAD_FUNCTION(mod_easyroute_load);
|
SWITCH_MODULE_LOAD_FUNCTION(mod_easyroute_load);
|
||||||
@ -120,6 +121,8 @@ static switch_status_t load_config(void)
|
|||||||
set_global_default_gateway(val);
|
set_global_default_gateway(val);
|
||||||
} else if (!strcasecmp(var, "custom-query")) {
|
} else if (!strcasecmp(var, "custom-query")) {
|
||||||
set_global_custom_query(val);
|
set_global_custom_query(val);
|
||||||
|
} else if (!strcasecmp(var, "odbc-retries")) {
|
||||||
|
globals.odbc_num_retries = atoi(val);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -143,6 +146,9 @@ static switch_status_t load_config(void)
|
|||||||
} else {
|
} else {
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Opened ODBC Database!\n");
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Opened ODBC Database!\n");
|
||||||
}
|
}
|
||||||
|
if (globals.odbc_num_retries) {
|
||||||
|
switch_odbc_set_num_retries(globals.master_odbc, globals.odbc_num_retries);
|
||||||
|
}
|
||||||
if (switch_odbc_handle_connect(globals.master_odbc) != SWITCH_ODBC_SUCCESS) {
|
if (switch_odbc_handle_connect(globals.master_odbc) != SWITCH_ODBC_SUCCESS) {
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Cannot Open ODBC Database!\n");
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Cannot Open ODBC Database!\n");
|
||||||
status = SWITCH_STATUS_FALSE;
|
status = SWITCH_STATUS_FALSE;
|
||||||
@ -205,7 +211,7 @@ static switch_status_t route_lookup(char *dn, easyroute_results_t *results, int
|
|||||||
switch_mutex_lock(globals.mutex);
|
switch_mutex_lock(globals.mutex);
|
||||||
}
|
}
|
||||||
/* Do the Query */
|
/* Do the Query */
|
||||||
if (switch_odbc_handle_callback_exec(globals.master_odbc, sql, route_callback, &pdata, NULL) == SWITCH_ODBC_SUCCESS) {
|
if (globals.master_odbc && switch_odbc_handle_callback_exec(globals.master_odbc, sql, route_callback, &pdata, NULL) == SWITCH_ODBC_SUCCESS) {
|
||||||
char tmp_profile[129];
|
char tmp_profile[129];
|
||||||
char tmp_gateway[129];
|
char tmp_gateway[129];
|
||||||
|
|
||||||
@ -418,7 +424,10 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_easyroute_load)
|
|||||||
|
|
||||||
SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_easyroute_shutdown)
|
SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_easyroute_shutdown)
|
||||||
{
|
{
|
||||||
switch_odbc_handle_disconnect(globals.master_odbc);
|
if (globals.master_odbc) {
|
||||||
|
switch_odbc_handle_disconnect(globals.master_odbc);
|
||||||
|
switch_odbc_handle_destroy(&globals.master_odbc);
|
||||||
|
}
|
||||||
switch_safe_free(globals.db_username);
|
switch_safe_free(globals.db_username);
|
||||||
switch_safe_free(globals.db_password);
|
switch_safe_free(globals.db_password);
|
||||||
switch_safe_free(globals.db_dsn);
|
switch_safe_free(globals.db_dsn);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user