]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
wait for cdr to be generated in failed cdr_x
authorAnthony Minessale <anthony.minessale@gmail.com>
Thu, 7 May 2009 17:27:15 +0000 (17:27 +0000)
committerAnthony Minessale <anthony.minessale@gmail.com>
Thu, 7 May 2009 17:27:15 +0000 (17:27 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@13253 d0543943-73ff-0310-b7d9-9358b9ac24b2

src/include/switch_channel.h
src/switch_channel.c
src/switch_ivr_originate.c

index 204229719d0b071f42b4d43e208dc1f40c8f7d24..e6fbe25f85c2eb7d973483065caea512751a6a95 100644 (file)
@@ -82,6 +82,7 @@ SWITCH_DECLARE(int) switch_channel_test_ready(switch_channel_t *channel, switch_
 #define switch_channel_down(_channel) (switch_channel_get_state(_channel) >= CS_HANGUP)
 
 SWITCH_DECLARE(void) switch_channel_wait_for_state(switch_channel_t *channel, switch_channel_t *other_channel, switch_channel_state_t want_state);
+SWITCH_DECLARE(void) switch_channel_wait_for_state_timeout(switch_channel_t *other_channel, switch_channel_state_t want_state, uint32_t timeout);
 SWITCH_DECLARE(switch_status_t) switch_channel_wait_for_flag(switch_channel_t *channel, 
                                                                                                                         switch_channel_flag_t want_flag, 
                                                                                                                         switch_bool_t pres, 
index f1a2472eb5b2dfec47d43306fbd691823304070f..346bb51c4e72becfba5995fc543d46561f9c5f6a 100644 (file)
@@ -771,6 +771,25 @@ SWITCH_DECLARE(void) switch_channel_wait_for_state(switch_channel_t *channel, sw
        }
 }
 
+
+SWITCH_DECLARE(void) switch_channel_wait_for_state_timeout(switch_channel_t *other_channel, switch_channel_state_t want_state, uint32_t timeout)
+{
+       switch_channel_state_t state;
+       uint32_t count = 0;
+
+       for (;;) {
+               state = switch_channel_get_running_state(other_channel);
+
+               if (state >= want_state) {
+                       break;
+               }
+               switch_cond_next();
+               if (++count >= timeout) {
+                       break;
+               }
+       }
+}
+
 SWITCH_DECLARE(switch_status_t) switch_channel_wait_for_flag(switch_channel_t *channel, 
                                                                                                                         switch_channel_flag_t want_flag, 
                                                                                                                         switch_bool_t pres, 
index 69cd01a256c2ee32c6f085010d49e90f7ead6139..c237be613fb145f4bd096be159ab9da807d1b77a 100644 (file)
@@ -2052,8 +2052,8 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess
                             continue;
                         }
                                                
-                                               switch_channel_wait_for_state(caller_channel, switch_core_session_get_channel(originate_status[i].peer_session), CS_DESTROY);
-
+                                               switch_channel_wait_for_state_timeout(switch_core_session_get_channel(originate_status[i].peer_session), CS_DESTROY, 5000);
+                                               
                                                if (switch_ivr_generate_xml_cdr(originate_status[i].peer_session, &cdr) == SWITCH_STATUS_SUCCESS) {
                                                        if ((xml_text = switch_xml_toxml(cdr, SWITCH_FALSE))) {
                                                                switch_snprintf(buf, sizeof(buf), "%s_%d", cdr_var, ++cdr_total);