mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-03-12 20:27:19 +00:00
prevent race on execute_on_answer called from the B-leg of a call
This commit is contained in:
parent
7e880ee33e
commit
751e0291ee
@ -1096,6 +1096,7 @@ typedef enum {
|
|||||||
CF_RECOVERED,
|
CF_RECOVERED,
|
||||||
CF_JITTERBUFFER,
|
CF_JITTERBUFFER,
|
||||||
CF_DIALPLAN,
|
CF_DIALPLAN,
|
||||||
|
CF_BLOCK_BROADCAST_UNTIL_MEDIA,
|
||||||
/* WARNING: DO NOT ADD ANY FLAGS BELOW THIS LINE */
|
/* WARNING: DO NOT ADD ANY FLAGS BELOW THIS LINE */
|
||||||
CF_FLAG_MAX
|
CF_FLAG_MAX
|
||||||
} switch_channel_flag_t;
|
} switch_channel_flag_t;
|
||||||
|
@ -1841,6 +1841,10 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_execute_application_async(sw
|
|||||||
switch_event_add_header_string(execute_event, SWITCH_STACK_BOTTOM, "execute-app-arg", arg);
|
switch_event_add_header_string(execute_event, SWITCH_STACK_BOTTOM, "execute-app-arg", arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!switch_channel_test_flag(session->channel, CF_PROXY_MODE)) {
|
||||||
|
switch_channel_set_flag(session->channel, CF_BLOCK_BROADCAST_UNTIL_MEDIA);
|
||||||
|
}
|
||||||
|
|
||||||
switch_event_add_header_string(execute_event, SWITCH_STACK_BOTTOM, "event-lock", "true");
|
switch_event_add_header_string(execute_event, SWITCH_STACK_BOTTOM, "event-lock", "true");
|
||||||
switch_core_session_queue_private_event(session, &execute_event, SWITCH_FALSE);
|
switch_core_session_queue_private_event(session, &execute_event, SWITCH_FALSE);
|
||||||
|
|
||||||
@ -1891,9 +1895,19 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_execute_application_get_flag
|
|||||||
switch_goto_status(SWITCH_STATUS_FALSE, done);
|
switch_goto_status(SWITCH_STATUS_FALSE, done);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING,
|
uint32_t ready = 0, sanity = 2000;
|
||||||
"Cannot execute app '%s' media required on an outbound channel that does not have media established\n", app);
|
|
||||||
switch_goto_status(SWITCH_STATUS_FALSE, done);
|
do {
|
||||||
|
sanity--;
|
||||||
|
ready = switch_channel_media_ready(session->channel);
|
||||||
|
switch_cond_next();
|
||||||
|
} while(!ready && sanity);
|
||||||
|
|
||||||
|
if (!ready) {
|
||||||
|
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING,
|
||||||
|
"Cannot execute app '%s' media required on an outbound channel that does not have media established\n", app);
|
||||||
|
switch_goto_status(SWITCH_STATUS_FALSE, done);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -698,12 +698,23 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_parse_all_messages(switch_core_sessio
|
|||||||
SWITCH_DECLARE(switch_status_t) switch_ivr_parse_all_events(switch_core_session_t *session)
|
SWITCH_DECLARE(switch_status_t) switch_ivr_parse_all_events(switch_core_session_t *session)
|
||||||
{
|
{
|
||||||
int x = 0;
|
int x = 0;
|
||||||
|
switch_channel_t *channel;
|
||||||
|
|
||||||
switch_ivr_parse_all_messages(session);
|
switch_ivr_parse_all_messages(session);
|
||||||
|
|
||||||
while (switch_ivr_parse_next_event(session) == SWITCH_STATUS_SUCCESS)
|
channel = switch_core_session_get_channel(session);
|
||||||
|
|
||||||
|
if (!switch_channel_test_flag(channel, CF_PROXY_MODE) && switch_channel_test_flag(channel, CF_BLOCK_BROADCAST_UNTIL_MEDIA)) {
|
||||||
|
if (switch_channel_media_ready(channel)) {
|
||||||
|
switch_channel_clear_flag(channel, CF_BLOCK_BROADCAST_UNTIL_MEDIA);
|
||||||
|
} else {
|
||||||
|
return SWITCH_STATUS_SUCCESS;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
while (switch_ivr_parse_next_event(session) == SWITCH_STATUS_SUCCESS) {
|
||||||
x++;
|
x++;
|
||||||
|
}
|
||||||
|
|
||||||
if (x) {
|
if (x) {
|
||||||
switch_ivr_sleep(session, 0, SWITCH_TRUE, NULL);
|
switch_ivr_sleep(session, 0, SWITCH_TRUE, NULL);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user