]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
refactor some of the message parsing code to use fifo to reduce threading contention
authorAnthony Minessale <anthony.minessale@gmail.com>
Mon, 12 Oct 2009 22:23:55 +0000 (22:23 +0000)
committerAnthony Minessale <anthony.minessale@gmail.com>
Mon, 12 Oct 2009 22:23:55 +0000 (22:23 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@15142 d0543943-73ff-0310-b7d9-9358b9ac24b2

16 files changed:
src/include/switch_core.h
src/include/switch_ivr.h
src/mod/applications/mod_conference/mod_conference.c
src/mod/endpoints/mod_alsa/mod_alsa.c
src/mod/endpoints/mod_dingaling/mod_dingaling.c
src/mod/endpoints/mod_iax/mod_iax.c
src/mod/endpoints/mod_portaudio/mod_portaudio.c
src/mod/endpoints/mod_sofia/sofia.c
src/switch_channel.c
src/switch_core_session.c
src/switch_core_state_machine.c
src/switch_ivr.c
src/switch_ivr_async.c
src/switch_ivr_bridge.c
src/switch_ivr_originate.c
src/switch_ivr_play_say.c

index 86bb3a9588e1d5205a9073bb234a64469ca2c3fa..bb5f507e42054455523f43fbd92e3b377c54890c 100644 (file)
@@ -59,6 +59,7 @@ struct switch_app_log {
        struct switch_app_log *next;
 };
 
+#define MESSAGE_STRING_ARG_MAX 10
 /*! \brief A message object designed to allow unlike technologies to exchange data */
 struct switch_core_session_message {
        /*! uuid of the sender (for replies) */
@@ -92,7 +93,7 @@ struct switch_core_session_message {
        const char *_file;
        const char *_func;
        int _line;
-       const char *string_array_arg[10];
+       const char *string_array_arg[MESSAGE_STRING_ARG_MAX];
 };
 
 /*! \brief A generic object to pass as a thread's session object to allow mutiple arguements and a pool */
@@ -634,6 +635,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_thread_launch(_In_ switch_co
 /*! 
   \brief Signal a session's state machine thread that a state change has occured
 */
+SWITCH_DECLARE(void) switch_core_session_wake_session_thread(_In_ switch_core_session_t *session);
 SWITCH_DECLARE(void) switch_core_session_signal_state_change(_In_ switch_core_session_t *session);
 
 /*! 
@@ -653,6 +655,10 @@ SWITCH_DECLARE(char *) switch_core_get_uuid(void);
 SWITCH_DECLARE(switch_core_session_t *) switch_core_session_perform_locate(const char *uuid_str, const char *file, const char *func, int line);
 #endif
 
+#ifdef SWITCH_DEBUG_RWLOCKS
+SWITCH_DECLARE(switch_core_session_t *) switch_core_session_perform_force_locate(const char *uuid_str, const char *file, const char *func, int line);
+#endif
+
 /*! 
   \brief Locate a session based on it's uuid
   \param uuid_str the unique id of the session you want to find
@@ -737,6 +743,8 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_message_send(_In_z_ const ch
 */
 SWITCH_DECLARE(switch_status_t) switch_core_session_queue_message(_In_ switch_core_session_t *session, _In_ switch_core_session_message_t *message);
 
+SWITCH_DECLARE(void) switch_core_session_free_message(switch_core_session_message_t **message);
+
 /*! 
   \brief pass an indication message on a session
   \param session the session to pass the message across
index a62d84d5503a4098459f1c20e99cdd4d228c2c3b..c47e3d9b58c1615789bdb3ef9741fc21c7baa8ac 100644 (file)
@@ -102,6 +102,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_parse_event(_In_ switch_core_session_
 */
 SWITCH_DECLARE(switch_status_t) switch_ivr_parse_all_events(switch_core_session_t *session);
 SWITCH_DECLARE(switch_status_t) switch_ivr_parse_next_event(switch_core_session_t *session);
+SWITCH_DECLARE(switch_status_t) switch_ivr_parse_all_messages(switch_core_session_t *session);
 
 /*!
   \brief Wait for time to pass for a specified number of milliseconds
index c0f4d03d20a2c420aa61b1a600c9f3ff49bee8be..8596aa85fb6098348b2de5e0a24b540e534b1e5d 100644 (file)
@@ -2359,6 +2359,8 @@ static void conference_loop_output(conference_member_t *member)
                        switch_channel_clear_app_flag(channel, CF_APP_TAGGED);
                        switch_set_flag_locked(member, MFLAG_FLUSH_BUFFER);
                        switch_core_session_set_read_codec(member->session, &member->read_codec);
+               } else {
+                       switch_ivr_parse_all_messages(member->session);
                }
                
                if (use_timer) {
index f094ded205746675b6f9654664856a4fea7976e7..14d1ed2392986c4349addb5a58b7184813174c07 100644 (file)
@@ -243,7 +243,6 @@ static switch_status_t channel_on_init(switch_core_session_t *session)
                        }
                }
 
-               switch_core_session_queue_indication(session, SWITCH_MESSAGE_INDICATE_RINGING);
                switch_channel_mark_ring_ready(channel);
 
                while (switch_channel_get_state(channel) == CS_INIT && !switch_test_flag(tech_pvt, TFLAG_ANSWER)) {
index 992db8d79c60789cb402eb0db7e93f3888b22bbb..c3ce666516920e15f4933376d4e7ec1e22639c5a 100644 (file)
@@ -1090,7 +1090,6 @@ static switch_status_t negotiate_media(switch_core_session_t *session)
        started = switch_micro_time_now();
 
        /* jingle has no ringing indication so we will just pretend that we got one */
-       switch_core_session_queue_indication(session, SWITCH_MESSAGE_INDICATE_RINGING);
        switch_channel_mark_ring_ready(channel);
 
        if (switch_test_flag(tech_pvt, TFLAG_OUTBOUND)) {
index e092cc4d50ab3772f08637ccc854c28404219d46..ffe02a7c0e2650fb50f7a9ef6e2609cf0728aef0 100644 (file)
@@ -1032,7 +1032,6 @@ SWITCH_MODULE_RUNTIME_FUNCTION(mod_iax_runtime)
                                break;
                        case IAX_EVENT_RINGA:
                                if (channel) {
-                                       switch_core_session_queue_indication(tech_pvt->session, SWITCH_MESSAGE_INDICATE_RINGING);
                                        switch_channel_mark_ring_ready(channel);
                                }
                                switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(channel), SWITCH_LOG_NOTICE, "Ringing heard.\n");
index db3edc14e0cf716bb2ebefab554fd7f9bc9908c1..7bef7485d48bec0995e311557b0b07f0ae7eb542 100644 (file)
@@ -248,7 +248,6 @@ static switch_status_t channel_on_init(switch_core_session_t *session)
                        switch_mutex_unlock(globals.pvt_lock);
                        switch_yield(1000000);
                } else {
-                       switch_core_session_queue_indication(session, SWITCH_MESSAGE_INDICATE_RINGING);
                        switch_channel_mark_ring_ready(channel);
                }
 
index 76561c1ab6e5812db6dd36d86398f46a6477de2a..926ce85cb21e1e55721c7e7a91907f8c904f8975 100644 (file)
@@ -401,13 +401,14 @@ void sofia_send_callee_id(switch_core_session_t *session, const char *name, cons
        }
        
        if ((uuid = switch_channel_get_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE)) && (session_b = switch_core_session_locate(uuid))) {
-               switch_core_session_message_t msg = { 0 };
+               switch_core_session_message_t *msg;
                
-               msg.message_id = SWITCH_MESSAGE_INDICATE_DISPLAY;
-               msg.string_array_arg[0] = name;
-               msg.string_array_arg[1] = number;
-               msg.from = __FILE__;
-               switch_core_session_receive_message(session_b, &msg);
+               msg = switch_core_session_alloc(session_b, sizeof(*msg));
+               msg->message_id = SWITCH_MESSAGE_INDICATE_DISPLAY;
+               msg->string_array_arg[0] = switch_core_session_strdup(session_b, name);
+               msg->string_array_arg[1] = switch_core_session_strdup(session_b, number);
+               msg->from = __FILE__;
+               switch_core_session_queue_message(session_b, msg);
                switch_core_session_rwunlock(session_b);
        }
 }
@@ -3275,7 +3276,7 @@ static void sofia_handle_sip_r_invite(switch_core_session_t *session, int status
 
                        if ((uuid = switch_channel_get_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE)) && (other_session = switch_core_session_locate(uuid))) {
                                const char *r_sdp = NULL;
-                               switch_core_session_message_t msg = { 0 };
+                               switch_core_session_message_t *msg;
 
                                if (sip->sip_payload && sip->sip_payload->pl_data &&
                                        sip->sip_content_type && sip->sip_content_type->c_subtype && switch_stristr("sdp", sip->sip_content_type->c_subtype)) {
@@ -3286,23 +3287,17 @@ static void sofia_handle_sip_r_invite(switch_core_session_t *session, int status
 
                                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Passing %d %s to other leg\n", status, phrase);
 
-                               msg.message_id = SWITCH_MESSAGE_INDICATE_RESPOND;
-                               msg.from = __FILE__;
-                               msg.numeric_arg = status;
-                               msg.string_arg = switch_core_session_strdup(other_session, phrase);
+                               msg = switch_core_session_alloc(other_session, sizeof(*msg));
+                               msg->message_id = SWITCH_MESSAGE_INDICATE_RESPOND;
+                               msg->from = __FILE__;
+                               msg->numeric_arg = status;
+                               msg->string_arg = switch_core_session_strdup(other_session, phrase);
                                if (r_sdp) {
-                                       msg.pointer_arg = switch_core_session_strdup(other_session, r_sdp);
-                                       msg.pointer_arg_size = strlen(r_sdp);
+                                       msg->pointer_arg = switch_core_session_strdup(other_session, r_sdp);
+                                       msg->pointer_arg_size = strlen(r_sdp);
                                }
 
-                               switch_mutex_unlock(tech_pvt->sofia_mutex);
-                               status = switch_core_session_receive_message(other_session, &msg);
-                               switch_mutex_lock(tech_pvt->sofia_mutex);
-
-                               if (status != SWITCH_STATUS_SUCCESS) {
-                                       switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Other leg is not available\n");
-                                       nua_respond(tech_pvt->nh, 403, "Hangup in progress", TAG_END());
-                               }
+                               switch_core_session_queue_message(other_session, msg);
                                switch_core_session_rwunlock(other_session);
                        }
                        return;
@@ -3550,23 +3545,6 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status,
        case nua_callstate_proceeding:
                if (status == 180) {
                        switch_channel_mark_ring_ready(channel);
-                       if (!switch_channel_test_flag(channel, CF_GEN_RINGBACK)) {
-                               if (switch_channel_test_flag(channel, CF_PROXY_MODE)) {
-                                       if ((uuid = switch_channel_get_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE))
-                                               && (other_session = switch_core_session_locate(uuid))) {
-                                               switch_core_session_message_t msg;
-                                               msg.message_id = SWITCH_MESSAGE_INDICATE_RINGING;
-                                               msg.from = __FILE__;
-                                               switch_mutex_unlock(tech_pvt->sofia_mutex);
-                                               switch_core_session_receive_message(other_session, &msg);
-                                               switch_mutex_lock(tech_pvt->sofia_mutex);
-                                               switch_core_session_rwunlock(other_session);
-                                       }
-
-                               } else {
-                                       switch_core_session_queue_indication(session, SWITCH_MESSAGE_INDICATE_RINGING);
-                               }
-                       }
                }
                        
                if (r_sdp) {
@@ -3582,7 +3560,7 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status,
                                                goto done;
                                        }
                                }
-                               if (!switch_channel_test_flag(channel, CF_GEN_RINGBACK) && (uuid = switch_channel_get_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE))
+                               if ((uuid = switch_channel_get_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE))
                                        && (other_session = switch_core_session_locate(uuid))) {
                                        other_channel = switch_core_session_get_channel(other_session);
                                        if (!switch_channel_get_variable(other_channel, SWITCH_B_SDP_VARIABLE)) {
@@ -3764,7 +3742,7 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status,
                                        
                                        if ((uuid = switch_channel_get_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE))
                                                && (other_session = switch_core_session_locate(uuid))) {
-                                               switch_core_session_message_t msg = { 0 };
+                                               switch_core_session_message_t *msg;
                                                
                                                if (profile->media_options & MEDIA_OPT_MEDIA_ON_HOLD) {
                                                        tech_pvt->hold_laps = 1;
@@ -3807,9 +3785,10 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status,
                                                        goto done;
                                                }
                                                
-                                               msg.message_id = SWITCH_MESSAGE_INDICATE_MEDIA_REDIRECT;
-                                               msg.from = __FILE__;
-                                               msg.string_arg = (char *) r_sdp;
+                                               msg = switch_core_session_alloc(other_session, sizeof(*msg));
+                                               msg->message_id = SWITCH_MESSAGE_INDICATE_MEDIA_REDIRECT;
+                                               msg->from = __FILE__;
+                                               msg->string_arg = switch_core_session_strdup(other_session, r_sdp);
                                                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Passing SDP to other leg.\n%s\n", r_sdp);
                                                
                                                if (sofia_test_flag(tech_pvt, TFLAG_SIP_HOLD)) {
@@ -3822,17 +3801,12 @@ static void sofia_handle_sip_i_state(switch_core_session_t *session, int status,
                                                        switch_channel_presence(tech_pvt->channel, "unknown", "hold", NULL);
                                                }
                                        
-                                               switch_mutex_unlock(tech_pvt->sofia_mutex);
-                                               status = switch_core_session_receive_message(other_session, &msg);
-                                               switch_mutex_lock(tech_pvt->sofia_mutex);
+                                               switch_core_session_queue_message(other_session, msg);
 
-                                               if (status != SWITCH_STATUS_SUCCESS) {
-                                                       switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Other leg is not available\n");
-                                                       nua_respond(tech_pvt->nh, 403, "Hangup in progress", TAG_END());
-                                               }
                                                switch_core_session_rwunlock(other_session);
                                        } else {
-                                               switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "Re-INVITE to a no-media channel that is not in a bridge.\n");
+                                               switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, 
+                                                                                 "Re-INVITE to a no-media channel that is not in a bridge.\n");
                                                is_ok = 0;
                                                switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
                                        }
index 85cead7c5ef59464e801d923532abff2be5c0bb8..2daf31c8eea0ea9582d77c31499b4b6a851cf418 100644 (file)
@@ -176,7 +176,7 @@ SWITCH_DECLARE(switch_call_cause_t) switch_channel_get_cause(switch_channel_t *c
 SWITCH_DECLARE(void) switch_channel_audio_sync(switch_channel_t *channel) 
 {
        if (switch_channel_media_ready(channel)) {
-               switch_core_session_message_t msg;
+               switch_core_session_message_t msg = { 0 };
                msg.message_id = SWITCH_MESSAGE_INDICATE_AUDIO_SYNC;
                msg.from = channel->name;
                switch_core_session_receive_message(channel->session, &msg);
@@ -1914,7 +1914,7 @@ SWITCH_DECLARE(switch_status_t) switch_channel_perform_mark_pre_answered(switch_
 
 SWITCH_DECLARE(switch_status_t) switch_channel_perform_pre_answer(switch_channel_t *channel, const char *file, const char *func, int line)
 {
-       switch_core_session_message_t msg;
+       switch_core_session_message_t msg = { 0 };
        switch_status_t status = SWITCH_STATUS_SUCCESS;
 
        switch_assert(channel != NULL);
@@ -1948,7 +1948,7 @@ SWITCH_DECLARE(switch_status_t) switch_channel_perform_pre_answer(switch_channel
 
 SWITCH_DECLARE(switch_status_t) switch_channel_perform_ring_ready(switch_channel_t *channel, const char *file, const char *func, int line)
 {
-       switch_core_session_message_t msg;
+       switch_core_session_message_t msg = { 0 };
        switch_status_t status = SWITCH_STATUS_SUCCESS;
 
        switch_assert(channel != NULL);
@@ -2064,7 +2064,7 @@ SWITCH_DECLARE(switch_status_t) switch_channel_perform_mark_answered(switch_chan
 
 SWITCH_DECLARE(switch_status_t) switch_channel_perform_answer(switch_channel_t *channel, const char *file, const char *func, int line)
 {
-       switch_core_session_message_t msg;
+       switch_core_session_message_t msg = { 0 };
        switch_status_t status = SWITCH_STATUS_SUCCESS;
 
        switch_assert(channel != NULL);
index 1544e884cf19d6968acbc08a41869ab27f4356ef..b3672f5fa9268efba1dedc86bd07ea2f703fdd06 100644 (file)
@@ -633,6 +633,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_perform_receive_message(swit
                break;
        }
 
+       switch_core_session_free_message(&message);
        switch_core_session_rwunlock(session);
 
        return status;
@@ -684,11 +685,37 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_queue_message(switch_core_se
                if (switch_queue_trypush(session->message_queue, message) == SWITCH_STATUS_SUCCESS) {
                        status = SWITCH_STATUS_SUCCESS;
                }
+
+               if (switch_channel_test_flag(session->channel, CF_PROXY_MODE)) {
+                       switch_core_session_wake_session_thread(session);
+               }
        }
 
        return status;
 }
 
+SWITCH_DECLARE(void) switch_core_session_free_message(switch_core_session_message_t **message)
+{
+       switch_core_session_message_t *to_free = *message;
+       int i;
+       char *s;
+
+       *message = NULL;
+
+       if (switch_test_flag(to_free, SCSMF_DYNAMIC)) {
+               s = (char *)to_free->string_arg;
+               switch_safe_free(s);
+               switch_safe_free(to_free->pointer_arg);
+               
+               for (i = 0; i < MESSAGE_STRING_ARG_MAX; i++) {
+                       s = (char *)to_free->string_array_arg[i];
+                       switch_safe_free(s);
+               }
+
+               switch_safe_free(to_free);
+       }
+}
+
 SWITCH_DECLARE(switch_status_t) switch_core_session_dequeue_message(switch_core_session_t *session, switch_core_session_message_t **message)
 {
        switch_status_t status = SWITCH_STATUS_FALSE;
@@ -709,12 +736,8 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_flush_message(switch_core_se
 {
        switch_core_session_message_t *message;
 
-       if (switch_core_session_dequeue_message(session, &message) == SWITCH_STATUS_SUCCESS) {
-               if (switch_test_flag(message, SCSMF_DYNAMIC)) {
-                       switch_safe_free(message);
-               } else {
-                       message = NULL;
-               }
+       while (switch_core_session_dequeue_message(session, &message) == SWITCH_STATUS_SUCCESS) {
+               switch_core_session_free_message(&message);
        }
 
        return SWITCH_STATUS_SUCCESS;
@@ -907,16 +930,21 @@ SWITCH_DECLARE(switch_channel_t *) switch_core_session_get_channel(switch_core_s
        return session->channel;
 }
 
-SWITCH_DECLARE(void) switch_core_session_signal_state_change(switch_core_session_t *session)
+SWITCH_DECLARE(void) switch_core_session_wake_session_thread(switch_core_session_t *session)
 {
-       switch_status_t status = SWITCH_STATUS_SUCCESS;
-       switch_io_event_hook_state_change_t *ptr;
-
        /* If trylock fails the signal is already awake so we needn't bother */
        if (switch_mutex_trylock(session->mutex) == SWITCH_STATUS_SUCCESS) {
                switch_thread_cond_signal(session->cond);
                switch_mutex_unlock(session->mutex);
        }
+}
+
+SWITCH_DECLARE(void) switch_core_session_signal_state_change(switch_core_session_t *session)
+{
+       switch_status_t status = SWITCH_STATUS_SUCCESS;
+       switch_io_event_hook_state_change_t *ptr;
+
+       switch_core_session_wake_session_thread(session);
 
        if (session->endpoint_interface->io_routines->state_change) {
                status = session->endpoint_interface->io_routines->state_change(session);
index 6cca5ea7ea7730a78e11450b3fc923feeb8737c1..6e70069851e33a9eac61def935c05b8c0deea0c2 100644 (file)
@@ -375,7 +375,19 @@ SWITCH_DECLARE(void) switch_core_session_run(switch_core_session_t *session)
                                        switch_channel_hangup(session->channel, SWITCH_CAUSE_INVALID_CALL_REFERENCE);
                                }
                        } else {
+                               switch_core_session_message_t *message;
+                                       
+                               while (switch_core_session_dequeue_message(session, &message) == SWITCH_STATUS_SUCCESS) {
+                                       switch_core_session_receive_message(session, message);
+                                       message = NULL;
+                               }
+                               
                                switch_thread_cond_wait(session->cond, session->mutex);
+                               
+                               while (switch_core_session_dequeue_message(session, &message) == SWITCH_STATUS_SUCCESS) {
+                                       switch_core_session_receive_message(session, message);
+                                       message = NULL;
+                               }
                        }
                }
        }
index 72dfebe4263ce992be3e3cdb901662081b3badc5..d3d2da3a1589e7964a4d2e7f945a0a4e8f65acb8 100644 (file)
@@ -220,9 +220,9 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_sleep(switch_core_session_t *session,
                        break;
                }
                
-               if (switch_core_session_private_event_count(session)) {
-                       switch_ivr_parse_all_events(session);
-               }
+
+               switch_ivr_parse_all_events(session);
+
 
                if (args && (args->input_callback || args->buf || args->buflen)) {
                        switch_dtmf_t dtmf;
@@ -624,10 +624,26 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_parse_next_event(switch_core_session_
 
 }
 
+SWITCH_DECLARE(switch_status_t) switch_ivr_parse_all_messages(switch_core_session_t *session)
+{
+       switch_core_session_message_t *message;
+       int i = 0;
+       
+       while (switch_core_session_dequeue_message(session, &message) == SWITCH_STATUS_SUCCESS) {
+               i++;
+               switch_core_session_receive_message(session, message);
+               message = NULL;
+       }
+
+       return i ? SWITCH_STATUS_SUCCESS : SWITCH_STATUS_FALSE;
+}
+
 SWITCH_DECLARE(switch_status_t) switch_ivr_parse_all_events(switch_core_session_t *session)
 {
 
+
        while (switch_ivr_parse_next_event(session) == SWITCH_STATUS_SUCCESS);
+       switch_ivr_parse_all_messages(session);
        switch_ivr_sleep(session, 0, SWITCH_TRUE, NULL);
 
        return SWITCH_STATUS_SUCCESS;
@@ -773,9 +789,8 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_park(switch_core_session_t *session,
                                }
                        }
 
-                       if (switch_core_session_private_event_count(session)) {
-                               switch_ivr_parse_all_events(session);
-                       }
+                       switch_ivr_parse_all_events(session);
+
 
                        if (switch_channel_has_dtmf(channel)) {
                                switch_dtmf_t dtmf = { 0 };
@@ -859,9 +874,9 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_collect_digits_callback(switch_core_s
                        }
                }
 
-               if (switch_core_session_private_event_count(session)) {
-                       switch_ivr_parse_all_events(session);
-               }
+
+               switch_ivr_parse_all_events(session);
+
 
                if (switch_channel_has_dtmf(channel)) {
                        switch_channel_dequeue_dtmf(channel, &dtmf);
@@ -990,9 +1005,9 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_collect_digits_count(switch_core_sess
                        }
                }
 
-               if (switch_core_session_private_event_count(session)) {
-                       switch_ivr_parse_all_events(session);
-               }
+
+               switch_ivr_parse_all_events(session);
+
 
                
                if (eff_timeout) {
index a60cbf5ce1613d623e537ded82e060c91b45efd4..50514f9d3bba71b45dec8d1a0953e6f79a3ab966 100644 (file)
@@ -100,9 +100,7 @@ SWITCH_DECLARE(void) switch_ivr_session_echo(switch_core_session_t *session, swi
                        break;
                }
 
-               if (switch_core_session_private_event_count(session)) {
-            switch_ivr_parse_all_events(session);
-        }
+               switch_ivr_parse_all_events(session);
 
                if (args && (args->input_callback || args->buf || args->buflen)) {
                        switch_dtmf_t dtmf;
index 66667cea2a19873005a42d557e3f37f14beebdfe..21f2c6aeba204465aa61d1fa1dd09500f7798c71 100644 (file)
@@ -357,11 +357,7 @@ static void *audio_bridge_thread(switch_thread_t *thread, void *obj)
 
                if (switch_core_session_dequeue_message(session_b, &message) == SWITCH_STATUS_SUCCESS) {
                        switch_core_session_receive_message(session_a, message);
-                       if (switch_test_flag(message, SCSMF_DYNAMIC)) {
-                               switch_safe_free(message);
-                       } else {
-                               message = NULL;
-                       }
+                       message = NULL;
                }
 
                if (!ans_a && answer_limit && switch_epoch_time_now(NULL) > answer_limit) {
index 6ba73cc5a9a1abfead994c3980a001ecf339b319..90681561007eaa9e0852482923c9786fe44203ef 100644 (file)
@@ -384,6 +384,9 @@ static uint8_t check_channel_status(originate_global_t *oglobals, originate_stat
 
                        if (!oglobals->ring_ready) {
                                oglobals->ring_ready = 1;
+                               if (caller_channel && !oglobals->ignore_ring_ready) {
+                                       switch_channel_ring_ready(caller_channel);
+                               }
                        }
                }
 
@@ -534,13 +537,12 @@ static uint8_t check_channel_status(originate_global_t *oglobals, originate_stat
                                
                                if (!oglobals->ring_ready && !oglobals->ignore_ring_ready) {
                                        oglobals->ring_ready = 1;
+                                       
                                }
                        }
                }
                
-               if (switch_core_session_private_event_count(originate_status[i].peer_session)) {
-                       switch_ivr_parse_all_events(originate_status[i].peer_session);
-               }
+               switch_ivr_parse_all_events(originate_status[i].peer_session);
 
                state = switch_channel_get_state(originate_status[i].peer_channel);
                if (state >= CS_HANGUP || state == CS_RESET || switch_channel_test_flag(originate_status[i].peer_channel, CF_TRANSFER) ||
@@ -659,7 +661,6 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_wait_for_answer(switch_core_session_t
        switch_codec_t *read_codec = switch_core_session_get_read_codec(session);
        uint8_t pass = 0;
        ringback_t ringback = { 0 };
-       switch_core_session_message_t *message = NULL;
        switch_frame_t *read_frame = NULL;
        switch_status_t status = SWITCH_STATUS_SUCCESS;
        int timelimit = 60;
@@ -848,15 +849,6 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_wait_for_answer(switch_core_session_t
                        goto done;
                }
 
-
-               if (switch_core_session_dequeue_message(peer_session, &message) == SWITCH_STATUS_SUCCESS) {
-                       if (switch_test_flag(message, SCSMF_DYNAMIC)) {
-                               switch_safe_free(message);
-                       } else {
-                               message = NULL;
-                       }
-               }
-               
                if (switch_channel_media_ready(caller_channel)) {
                        status = switch_core_session_read_frame(session, &read_frame, SWITCH_IO_FLAG_NONE, 0);
                        if (!SWITCH_READ_ACCEPTABLE(status)) {
@@ -1991,7 +1983,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess
                                
                                check_per_channel_timeouts(&oglobals, originate_status, and_argc, start);
 
-                               if (oglobals.session && switch_core_session_private_event_count(oglobals.session)) {
+                               if (oglobals.session) {
                                        switch_ivr_parse_all_events(oglobals.session);
                                }
 
@@ -2035,17 +2027,12 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess
                                }
 
                                if (originate_status[0].peer_session
-                                       && switch_core_session_dequeue_message(originate_status[0].peer_session, &message) == SWITCH_STATUS_SUCCESS) {
+                                       && switch_core_session_dequeue_message(oglobals.session, &message) == SWITCH_STATUS_SUCCESS) {
                                        if (oglobals.session && !ringback_data && or_argc == 1 && and_argc == 1) {      
                                                /* when there is only 1 channel to call and bridge and no ringback */
                                                switch_core_session_receive_message(oglobals.session, message);
                                        }
-
-                                       if (switch_test_flag(message, SCSMF_DYNAMIC)) {
-                                               switch_safe_free(message);
-                                       } else {
-                                               message = NULL;
-                                       }
+                                       message = NULL;
                                }
 
                                /* read from the channel while we wait if the audio is up on it */
index 29d43fdd8404f988b7b1573879038b2864cffa67..bfc3dc8df1eb7a936ac627f56f557035eeb52184 100644 (file)
@@ -612,9 +612,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_record_file(switch_core_session_t *se
                        break;
                }
 
-               if (switch_core_session_private_event_count(session)) {
-                       switch_ivr_parse_all_events(session);
-               }
+               switch_ivr_parse_all_events(session);
 
                if (start && (switch_epoch_time_now(NULL) - start) > limit) {
                        break;
@@ -803,9 +801,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_gentones(switch_core_session_t *sessi
                        break;
                }
 
-               if (switch_core_session_private_event_count(session)) {
-            switch_ivr_parse_all_events(session);
-        }
+               switch_ivr_parse_all_events(session);
 
                if (args && (args->input_callback || args->buf || args->buflen)) {
                        /*
@@ -1193,9 +1189,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_play_file(switch_core_session_t *sess
                                break; 
                        }
 
-                       if (switch_core_session_private_event_count(session)) {
-                               switch_ivr_parse_all_events(session);
-                       }
+                       switch_ivr_parse_all_events(session);
 
                        if (args && (args->input_callback || args->buf || args->buflen)) {
                                /*