]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
fix edge case endless loop that can get a channel stuck
authorAnthony Minessale <anthm@freeswitch.org>
Wed, 11 Jan 2012 18:05:16 +0000 (12:05 -0600)
committerAnthony Minessale <anthm@freeswitch.org>
Wed, 11 Jan 2012 18:05:16 +0000 (12:05 -0600)
src/switch_channel.c
src/switch_ivr_bridge.c

index 435c2a3929cc63ed98ba44c7e4085d1a74e8c43a..df3bedeacfb574b25b9b7a5f1aa3f82c1d98192b 100644 (file)
@@ -1383,7 +1383,7 @@ SWITCH_DECLARE(void) switch_channel_wait_for_state(switch_channel_t *channel, sw
        switch_assert(channel);
        
        for (;;) {
-               if ((channel->state == channel->running_state && channel->running_state == want_state) ||
+               if ((channel->state < CS_HANGUP && channel->state == channel->running_state && channel->running_state == want_state) ||
                        (other_channel && switch_channel_down_nosig(other_channel)) || switch_channel_down_nosig(channel)) {
                        break;
                }
index 6fd926d6c5cb5495758c20c2d88db3eafd9c3f99..3096f9cf92fa9daaa95676ba2c3b69558f69562b 100644 (file)
@@ -776,17 +776,17 @@ static switch_status_t uuid_bridge_on_soft_execute(switch_core_session_t *sessio
                        state = switch_channel_get_state(other_channel);
                        running_state = switch_channel_get_running_state(other_channel);
 
-                       if (state == running_state) {
+                       if (switch_channel_down_nosig(other_channel) || switch_channel_down_nosig(channel)) {
+                               break;
+                       }
+
+                       if (state < CS_HANGUP && state == running_state) {
                                
                                if (--loops < 1) {
                                        switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
                                        switch_channel_hangup(other_channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
                                }
 
-                               if (switch_channel_down_nosig(other_channel) || switch_channel_down_nosig(channel)) {
-                                       break;
-                               }
-
                                if (running_state == CS_RESET) {
                                        switch_channel_set_state(other_channel, CS_SOFT_EXECUTE);
                                }
@@ -803,7 +803,7 @@ static switch_status_t uuid_bridge_on_soft_execute(switch_core_session_t *sessio
                        } else {
                                loops = max;
                        }
-
+                       
                        switch_yield(20000);
                }