]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
update watchdog code
authorAnthony Minessale <anthm@freeswitch.org>
Wed, 6 Oct 2010 21:05:00 +0000 (16:05 -0500)
committerAnthony Minessale <anthm@freeswitch.org>
Wed, 6 Oct 2010 21:05:13 +0000 (16:05 -0500)
src/mod/endpoints/mod_sofia/sofia.c

index 0598624c63c166fb0f004019be5f38f1591933f3..4007187e26a47f4b6970da0669b0d4a4af29a60b 100644 (file)
@@ -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);