git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@7949 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Anthony Minessale 2008-03-20 19:29:18 +00:00
parent d86185c4ae
commit e34e139f8b
1 changed files with 17 additions and 2 deletions

View File

@ -295,7 +295,8 @@ SWITCH_MODULE_RUNTIME_FUNCTION(softtimer_runtime)
uint32_t current_ms = 0; uint32_t current_ms = 0;
uint32_t x, tick = 0; uint32_t x, tick = 0;
switch_time_t ts = 0, last = 0; switch_time_t ts = 0, last = 0;
int fwd_errs = 0, rev_errs = 0;
switch_time_sync(); switch_time_sync();
memset(&globals, 0, sizeof(globals)); memset(&globals, 0, sizeof(globals));
@ -324,6 +325,7 @@ SWITCH_MODULE_RUNTIME_FUNCTION(softtimer_runtime)
ts = 0; ts = 0;
last = 0; last = 0;
fwd_errs = rev_errs = 0;
while (globals.RUNNING == 1) { while (globals.RUNNING == 1) {
runtime.reference += STEP_MIC; runtime.reference += STEP_MIC;
@ -335,20 +337,33 @@ SWITCH_MODULE_RUNTIME_FUNCTION(softtimer_runtime)
current_ms = 0; current_ms = 0;
tick = 0; tick = 0;
runtime.initiated += diff; runtime.initiated += diff;
rev_errs++;
} else {
rev_errs = 0;
} }
switch_yield(STEP_MIC); switch_yield(STEP_MIC);
last = ts; last = ts;
} }
if (ts > (runtime.reference + too_late)) { if (ts > (runtime.reference + too_late)) {
switch_time_t diff = ts - runtime.reference - STEP_MIC; switch_time_t diff = ts - runtime.reference - STEP_MIC;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Forward Clock Skew Detected!\n"); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Forward Clock Skew Detected!\n");
fwd_errs++;
runtime.reference = switch_time_now(); runtime.reference = switch_time_now();
current_ms = 0; current_ms = 0;
tick = 0; tick = 0;
runtime.initiated += diff; runtime.initiated += diff;
} else {
fwd_errs = 0;
} }
if (fwd_errs > 9 || rev_errs > 9) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Auto Re-Syncing clock.\n");
switch_time_sync();
fwd_errs = rev_errs = 0;
}
runtime.timestamp = ts; runtime.timestamp = ts;
current_ms += STEP_MS; current_ms += STEP_MS;
tick += STEP_MS; tick += STEP_MS;