From: Anthony Minessale Date: Wed, 6 Oct 2010 21:05:00 +0000 (-0500) Subject: update watchdog code X-Git-Tag: v1.2-rc1~291^2~7^2~8^2~27 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=430fb980507cf47cc9f1f97a00f1a7c284801dba;p=thirdparty%2Ffreeswitch.git update watchdog code --- diff --git a/src/mod/endpoints/mod_sofia/sofia.c b/src/mod/endpoints/mod_sofia/sofia.c index 0598624c63..4007187e26 100644 --- a/src/mod/endpoints/mod_sofia/sofia.c +++ b/src/mod/endpoints/mod_sofia/sofia.c @@ -1310,33 +1310,40 @@ void *SWITCH_THREAD_FUNC sofia_profile_worker_thread_run(switch_thread_t *thread } if (++loops >= 1000) { - uint32_t diff = 0, fail = 0; + - if (profile->step_timeout) { - diff = (uint32_t) ((switch_time_now() - profile->last_root_step) / 1000); - if (diff > profile->step_timeout) { - fail = 1; + + if (profile->watchdog_enabled) { + uint32_t event_diff = 0, step_diff = 0, event_fail = 0, step_fail = 0; + + if (profile->step_timeout) { + step_diff = (uint32_t) ((switch_time_now() - profile->last_root_step) / 1000); + + if (step_diff > profile->step_timeout) { + step_fail = 1; + } } - } - if (profile->event_timeout) { - diff = (uint32_t) ((switch_time_now() - profile->last_sip_event) / 1000); - if (diff > profile->event_timeout) { - fail = 1; + if (profile->event_timeout) { + event_diff = (uint32_t) ((switch_time_now() - profile->last_sip_event) / 1000); + + if (event_diff > profile->event_timeout) { + event_fail = 1; + } } - } - if (profile->watchdog_enabled && fail) { - int arg = 1; - switch_session_ctl_t command = SCSC_SHUTDOWN_NOW; + if (step_fail && profile->event_timeout && !event_fail) { + step_fail = 0; + } - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Profile %s: SIP STACK FAILURE DETECTED!\n" - "GOODBYE CRUEL WORLD, I'M LEAVING YOU TODAY....GOODBYE, GOODBYE, GOOD BYE\n", profile->name); - switch_yield(2000); - switch_core_session_ctl(command, &arg); + if (event_fail || step_fail) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Profile %s: SIP STACK FAILURE DETECTED!\n" + "GOODBYE CRUEL WORLD, I'M LEAVING YOU TODAY....GOODBYE, GOODBYE, GOOD BYE\n", profile->name); + switch_yield(2000); + abort(); + } } - if (++ireg_loops >= IREG_SECONDS) { time_t now = switch_epoch_time_now(NULL); sofia_reg_check_expire(profile, now, 0);