diff --git a/src/mod/applications/mod_cidlookup/mod_cidlookup.c b/src/mod/applications/mod_cidlookup/mod_cidlookup.c index 2e7b063a38..96c85cb1a0 100755 --- a/src/mod/applications/mod_cidlookup/mod_cidlookup.c +++ b/src/mod/applications/mod_cidlookup/mod_cidlookup.c @@ -93,7 +93,7 @@ static switch_cache_db_handle_t *cidlookup_get_db_handle(void) switch_cache_db_connection_options_t options = { {0} }; switch_cache_db_handle_t *dbh = NULL; - if (globals.odbc_dsn && globals.odbc_user && globals.odbc_pass) { + if (!zstr(globals.odbc_dsn)) { options.odbc_options.dsn = globals.odbc_dsn; options.odbc_options.user = globals.odbc_user; options.odbc_options.pass = globals.odbc_pass; diff --git a/src/mod/applications/mod_fifo/mod_fifo.c b/src/mod/applications/mod_fifo/mod_fifo.c index fcc05cc5eb..d98cc70b03 100644 --- a/src/mod/applications/mod_fifo/mod_fifo.c +++ b/src/mod/applications/mod_fifo/mod_fifo.c @@ -289,7 +289,7 @@ switch_cache_db_handle_t *fifo_get_db_handle(void) switch_cache_db_connection_options_t options = { {0} }; switch_cache_db_handle_t *dbh = NULL; - if (globals.odbc_dsn && globals.odbc_user && globals.odbc_pass) { + if (!zstr(globals.odbc_dsn)) { options.odbc_options.dsn = globals.odbc_dsn; options.odbc_options.user = globals.odbc_user; options.odbc_options.pass = globals.odbc_pass; @@ -1873,8 +1873,6 @@ static switch_status_t load_config(int reload, int del_all) { char *cf = "fifo.conf"; switch_xml_t cfg, xml, fifo, fifos, member, settings, param; - char *odbc_user = NULL; - char *odbc_pass = NULL; switch_status_t status = SWITCH_STATUS_SUCCESS; char *sql; switch_bool_t delete_all_outbound_member_on_startup = SWITCH_FALSE; @@ -1913,7 +1911,7 @@ static switch_status_t load_config(int reload, int del_all) } } - if (zstr(globals.odbc_dsn) || zstr(odbc_user) || zstr(odbc_pass)) { + if (zstr(globals.odbc_dsn)) { globals.dbname = "fifo"; } diff --git a/src/mod/applications/mod_lcr/mod_lcr.c b/src/mod/applications/mod_lcr/mod_lcr.c index 7b593324bf..eb8402360c 100644 --- a/src/mod/applications/mod_lcr/mod_lcr.c +++ b/src/mod/applications/mod_lcr/mod_lcr.c @@ -394,7 +394,7 @@ static switch_cache_db_handle_t *lcr_get_db_handle(void) switch_cache_db_connection_options_t options = { {0} }; switch_cache_db_handle_t *dbh = NULL; - if (globals.odbc_dsn && globals.odbc_user && globals.odbc_pass) { + if (!zstr(globals.odbc_dsn)) { options.odbc_options.dsn = globals.odbc_dsn; options.odbc_options.user = globals.odbc_user; options.odbc_options.pass = globals.odbc_pass; diff --git a/src/mod/applications/mod_limit/mod_limit.c b/src/mod/applications/mod_limit/mod_limit.c index 93b19b765c..40720385f1 100644 --- a/src/mod/applications/mod_limit/mod_limit.c +++ b/src/mod/applications/mod_limit/mod_limit.c @@ -95,7 +95,7 @@ switch_cache_db_handle_t *limit_get_db_handle(void) switch_cache_db_connection_options_t options = { {0} }; switch_cache_db_handle_t *dbh = NULL; - if (globals.odbc_dsn && globals.odbc_user && globals.odbc_pass) { + if (!zstr(globals.odbc_dsn)) { options.odbc_options.dsn = globals.odbc_dsn; options.odbc_options.user = globals.odbc_user; options.odbc_options.pass = globals.odbc_pass; @@ -205,7 +205,7 @@ static switch_status_t do_config() } - if (zstr(globals.odbc_dsn) || zstr(globals.odbc_user) || zstr(globals.odbc_pass)) { + if (zstr(globals.odbc_dsn)) { globals.dbname = "call_limit"; dbh = limit_get_db_handle(); } diff --git a/src/mod/applications/mod_voicemail/mod_voicemail.c b/src/mod/applications/mod_voicemail/mod_voicemail.c index fa641ad5a1..d4bcb9d8b9 100644 --- a/src/mod/applications/mod_voicemail/mod_voicemail.c +++ b/src/mod/applications/mod_voicemail/mod_voicemail.c @@ -158,7 +158,7 @@ switch_cache_db_handle_t *vm_get_db_handle(vm_profile_t *profile) switch_cache_db_connection_options_t options = { {0} }; switch_cache_db_handle_t *dbh = NULL; - if (profile->odbc_dsn && profile->odbc_user && profile->odbc_pass) { + if (!zstr(profile->odbc_dsn)) { options.odbc_options.dsn = profile->odbc_dsn; options.odbc_options.user = profile->odbc_user; options.odbc_options.pass = profile->odbc_pass; diff --git a/src/mod/endpoints/mod_sofia/sofia_glue.c b/src/mod/endpoints/mod_sofia/sofia_glue.c index 191285e659..4d5923520d 100644 --- a/src/mod/endpoints/mod_sofia/sofia_glue.c +++ b/src/mod/endpoints/mod_sofia/sofia_glue.c @@ -4208,7 +4208,7 @@ switch_cache_db_handle_t *sofia_glue_get_db_handle(sofia_profile_t *profile) switch_cache_db_connection_options_t options = { {0} }; switch_cache_db_handle_t *dbh = NULL; - if (profile->odbc_dsn && profile->odbc_user && profile->odbc_pass) { + if (!zstr(profile->odbc_dsn)) { options.odbc_options.dsn = profile->odbc_dsn; options.odbc_options.user = profile->odbc_user; options.odbc_options.pass = profile->odbc_pass; diff --git a/src/switch_core_sqldb.c b/src/switch_core_sqldb.c index f85eb1aa24..9867c79f05 100644 --- a/src/switch_core_sqldb.c +++ b/src/switch_core_sqldb.c @@ -58,7 +58,7 @@ SWITCH_DECLARE(switch_status_t) _switch_core_db_handle(switch_cache_db_handle_t switch_cache_db_connection_options_t options = { {0} }; switch_status_t r; - if (runtime.odbc_dsn && runtime.odbc_user && runtime.odbc_pass) { + if (!zstr(runtime.odbc_dsn)) { options.odbc_options.dsn = runtime.odbc_dsn; options.odbc_options.user = runtime.odbc_user; options.odbc_options.pass = runtime.odbc_pass; diff --git a/src/switch_time.c b/src/switch_time.c index 42d761a937..0e44a8fd91 100644 --- a/src/switch_time.c +++ b/src/switch_time.c @@ -176,29 +176,39 @@ static switch_interval_time_t average_time(switch_interval_time_t t, int reps) } +#define calc_step() if ((step - 10) > 10) step -= 10; else if (step > 1) step-- static void calibrate_clock(void) { int x; switch_interval_time_t avg, val = 1000, want = 1000; - int over = 0, under = 0, good = 0; + int over = 0, under = 0, good = 0, step = 50; for (x = 0; x < 500; x++) { avg = average_time(val, 100); - + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Test: %ld Average: %ld Step: %d\n", val, avg, step); + if (abs((int)(want - avg)) <= 2) { + under = over = 0; if (++good > 10) { break; } } else if (avg > want) { - val--; - over++; + under = 0; + val -= step; + if (++over > 3) { + calc_step(); + } } else if (avg < want) { - val++; - under++; + over = 0; + val += step; + if (++under > 3) { + calc_step(); + } } } OFFSET = (int)(want - val); + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Timer offset of %d calculated\n", OFFSET); } @@ -289,7 +299,7 @@ SWITCH_DECLARE(void) switch_micro_sleep(switch_interval_time_t t) SWITCH_DECLARE(void) switch_sleep(switch_interval_time_t t) { - if (!globals.RUNNING || t < 1000 || t >= 10000) { + if (globals.RUNNING != 1 || t < 1000 || t >= 10000) { do_sleep(t); return; } @@ -580,7 +590,7 @@ SWITCH_MODULE_RUNTIME_FUNCTION(softtimer_runtime) } #endif - calibrate_clock(); + switch_time_sync(); globals.use_cond_yield = COND; @@ -917,6 +927,9 @@ SWITCH_MODULE_LOAD_FUNCTION(softtimer_load) timer_interface->timer_check = timer_check; timer_interface->timer_destroy = timer_destroy; + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Calibrating timer, please wait...\n"); + calibrate_clock(); + /* indicate that the module should continue to be loaded */ return SWITCH_STATUS_SUCCESS; } diff --git a/support-d/.bashrc b/support-d/.bashrc index 1ac8be78ed..1ffb31635d 100644 --- a/support-d/.bashrc +++ b/support-d/.bashrc @@ -27,8 +27,8 @@ alias mcommit='svn commit --no-auth-cache --username=mikej' alias bcommit='svn commit --no-auth-cache --username=brian' alias icommit='svn commit --no-auth-cache --username=intralanman' alias dp='emacs /usr/local/freeswitch/conf/dialplan/default.xml' -alias fstop='top -p `cat /usr/local/freeswitch/log/freeswitch.pid`' -alias fsgdb='gdb /usr/local/freeswitch/bin/freeswitch `cat /usr/local/freeswitch/log/freeswitch.pid`' +alias fstop='top -p `cat /usr/local/freeswitch/run/freeswitch.pid`' +alias fsgdb='gdb /usr/local/freeswitch/bin/freeswitch `cat /usr/local/freeswitch/run/freeswitch.pid`' alias fscore='gdb /usr/local/freeswitch/bin/freeswitch `ls -rt core.* | tail -n1`' alias emacs='emacs -nw' # End of file