From 1c9fe263d67c0828615857e4dfd8c40dad61f295 Mon Sep 17 00:00:00 2001 From: David Yat Sin Date: Thu, 23 Sep 2010 13:58:20 -0400 Subject: [PATCH] Changed ftdm_cpu_monitor behaviour --- libs/freetdm/mod_freetdm/mod_freetdm.c | 2 -- libs/freetdm/src/ftdm_io.c | 28 +++++++++++-------- .../ftmod_sangoma_isdn_stack_cfg.c | 3 +- 3 files changed, 19 insertions(+), 14 deletions(-) diff --git a/libs/freetdm/mod_freetdm/mod_freetdm.c b/libs/freetdm/mod_freetdm/mod_freetdm.c index 086cc4ae2e..3ad4393ab5 100755 --- a/libs/freetdm/mod_freetdm/mod_freetdm.c +++ b/libs/freetdm/mod_freetdm/mod_freetdm.c @@ -4099,8 +4099,6 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_freetdm_load) ftdm_global_set_config_directory(SWITCH_GLOBAL_dirs.conf_dir); - ftdm_cpu_monitor_disable(); - if (ftdm_global_init() != FTDM_SUCCESS) { ftdm_log(FTDM_LOG_ERROR, "Error loading FreeTDM\n"); return SWITCH_STATUS_TERM; diff --git a/libs/freetdm/src/ftdm_io.c b/libs/freetdm/src/ftdm_io.c index 0cb217065a..18ae87c540 100644 --- a/libs/freetdm/src/ftdm_io.c +++ b/libs/freetdm/src/ftdm_io.c @@ -86,6 +86,7 @@ FT_DECLARE(ftdm_time_t) ftdm_current_time_in_ms(void) } typedef struct { + uint8_t enabled; uint8_t running; uint8_t alarm; uint32_t interval; @@ -112,8 +113,6 @@ static struct { cpu_monitor_t cpu_monitor; } globals; -static uint8_t ftdm_cpu_monitor_disabled = 0; - enum ftdm_enum_cpu_alarm_action_flags { FTDM_CPU_ALARM_ACTION_WARN = (1 << 0), @@ -4004,7 +4003,14 @@ static ftdm_status_t load_config(void) ftdm_log(FTDM_LOG_ERROR, "unknown span variable '%s'\n", var); } } else if (!strncasecmp(cfg.category, "general", 7)) { - if (!strncasecmp(var, "cpu_monitoring_interval", sizeof("cpu_monitoring_interval")-1)) { + if (!strncasecmp(var, "cpu_monitor", sizeof("cpu_monitor")-1)) { + if (!strncasecmp(val, "yes", 3)) { + globals.cpu_monitor.enabled = 1; + if (!globals.cpu_monitor.alarm_action_flags) { + globals.cpu_monitor.alarm_action_flags |= FTDM_CPU_ALARM_ACTION_WARN; + } + } + } else if (!strncasecmp(var, "cpu_monitoring_interval", sizeof("cpu_monitoring_interval")-1)) { if (atoi(val) > 0) { globals.cpu_monitor.interval = atoi(val); } else { @@ -4749,12 +4755,6 @@ static void ftdm_cpu_monitor_stop(void) ftdm_interrupt_destroy(&globals.cpu_monitor.interrupt); } -FT_DECLARE(void) ftdm_cpu_monitor_disable(void) -{ - ftdm_cpu_monitor_disabled = 1; -} - - FT_DECLARE(ftdm_status_t) ftdm_global_init(void) { memset(&globals, 0, sizeof(globals)); @@ -4796,8 +4796,9 @@ FT_DECLARE(ftdm_status_t) ftdm_global_configuration(void) ftdm_log(FTDM_LOG_NOTICE, "Modules configured: %d \n", modcount); + globals.cpu_monitor.enabled = 0; globals.cpu_monitor.interval = 1000; - globals.cpu_monitor.alarm_action_flags = FTDM_CPU_ALARM_ACTION_WARN | FTDM_CPU_ALARM_ACTION_REJECT; + globals.cpu_monitor.alarm_action_flags = 0; globals.cpu_monitor.set_alarm_threshold = 80; globals.cpu_monitor.reset_alarm_threshold = 70; @@ -4807,7 +4808,12 @@ FT_DECLARE(ftdm_status_t) ftdm_global_configuration(void) return FTDM_FAIL; } - if (!ftdm_cpu_monitor_disabled) { + if (globals.cpu_monitor.enabled) { + ftdm_log(FTDM_LOG_INFO, "CPU Monitor is running interval:%d lo-thres:%d hi-thres:%d\n", + globals.cpu_monitor.interval, + globals.cpu_monitor.set_alarm_threshold, + globals.cpu_monitor.reset_alarm_threshold); + if (ftdm_cpu_monitor_start() != FTDM_SUCCESS) { return FTDM_FAIL; } diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_cfg.c b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_cfg.c index 942c2e4531..3a4a001089 100644 --- a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_cfg.c +++ b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn_stack_cfg.c @@ -608,9 +608,10 @@ ftdm_status_t sng_isdn_stack_cfg_q931_dlsap(ftdm_span_t *span) cfg.hdr.entId.ent = ENTIN; cfg.hdr.entId.inst = S_INST; cfg.hdr.elmId.elmnt = STDLSAP; - + cfg.hdr.response.selector=0; + cfg.t.cfg.s.inDLSAP.sapId = signal_data->link_id; cfg.t.cfg.s.inDLSAP.spId = signal_data->link_id; cfg.t.cfg.s.inDLSAP.swtch = sng_isdn_stack_switchtype(signal_data->switchtype);