add fsctl min_idle_cpu and min-idle-cpu feature to refuse calls after the system fallse below a certian percentage of idle cpu

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@16962 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Anthony Minessale
2010-03-10 20:21:34 +00:00
parent 869c221f3a
commit b1ddb70cf1
8 changed files with 94 additions and 26 deletions

View File

@@ -630,6 +630,10 @@ SWITCH_MODULE_RUNTIME_FUNCTION(softtimer_runtime)
uint32_t x, tick = 0;
switch_time_t ts = 0, last = 0;
int fwd_errs = 0, rev_errs = 0;
int profile_tick = 0;
runtime.profile_timer = switch_new_profile_timer();
switch_get_system_idle_time(runtime.profile_timer, &runtime.profile_time);
#ifdef HAVE_CPU_SET_MACROS
if (runtime.timer_affinity > -1) {
@@ -741,6 +745,11 @@ SWITCH_MODULE_RUNTIME_FUNCTION(softtimer_runtime)
tick += STEP_MS;
if (tick >= TICK_PER_SEC) {
if (++profile_tick == 1) {
switch_get_system_idle_time(runtime.profile_timer, &runtime.profile_time);
profile_tick = 0;
}
if (runtime.sps <= 0) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Over Session Rate of %d!\n", runtime.sps_total);
}
@@ -803,6 +812,8 @@ SWITCH_MODULE_RUNTIME_FUNCTION(softtimer_runtime)
globals.RUNNING = 0;
switch_mutex_unlock(globals.mutex);
switch_delete_profile_timer(&runtime.profile_timer);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Soft timer thread exiting.\n");
return SWITCH_STATUS_TERM;