fix super sonic race at 400 cps conditions

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@7845 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Anthony Minessale 2008-03-08 21:07:15 +00:00
parent 8b130b2ebd
commit 4a132c95a5
3 changed files with 13 additions and 16 deletions

View File

@ -80,9 +80,9 @@ SWITCH_DECLARE(switch_status_t) switch_channel_wait_for_flag(switch_channel_t *c
SWITCH_DECLARE(switch_channel_state_t) switch_channel_perform_set_state(switch_channel_t *channel, SWITCH_DECLARE(switch_channel_state_t) switch_channel_perform_set_state(switch_channel_t *channel,
const char *file, const char *func, int line, switch_channel_state_t state); const char *file, const char *func, int line, switch_channel_state_t state);
SWITCH_DECLARE(switch_channel_state_t) switch_channel_perform_set_running_state(switch_channel_t *channel, SWITCH_DECLARE(switch_channel_state_t) switch_channel_perform_set_running_state(switch_channel_t *channel, switch_channel_state_t state,
const char *file, const char *func, int line); const char *file, const char *func, int line);
#define switch_channel_set_running_state(channel) switch_channel_perform_set_running_state(channel, __FILE__, __SWITCH_FUNC__, __LINE__) #define switch_channel_set_running_state(channel, state) switch_channel_perform_set_running_state(channel, state, __FILE__, __SWITCH_FUNC__, __LINE__)
/*! /*!
\brief Set the current state of a channel \brief Set the current state of a channel

View File

@ -763,13 +763,13 @@ SWITCH_DECLARE(switch_channel_state_t) switch_channel_name_state(const char *nam
return CS_DONE; return CS_DONE;
} }
SWITCH_DECLARE(switch_channel_state_t) switch_channel_perform_set_running_state(switch_channel_t *channel, SWITCH_DECLARE(switch_channel_state_t) switch_channel_perform_set_running_state(switch_channel_t *channel, switch_channel_state_t state,
const char *file, const char *func, int line) const char *file, const char *func, int line)
{ {
switch_mutex_lock(channel->flag_mutex); switch_mutex_lock(channel->flag_mutex);
switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, NULL, SWITCH_LOG_DEBUG, "%s Running State Change %s\n", switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, NULL, SWITCH_LOG_DEBUG, "%s Running State Change %s\n",
channel->name, state_names[channel->state]); channel->name, state_names[state]);
channel->running_state = channel->state; channel->running_state = state;
if (channel->state_flags) { if (channel->state_flags) {
channel->flags |= channel->state_flags; channel->flags |= channel->state_flags;
@ -778,18 +778,18 @@ SWITCH_DECLARE(switch_channel_state_t) switch_channel_perform_set_running_state(
if (channel->state >= CS_RING) { if (channel->state >= CS_RING) {
switch_clear_flag(channel, CF_TRANSFER); switch_clear_flag(channel, CF_TRANSFER);
switch_channel_presence(channel, "unknown", (char *) state_names[channel->state]); switch_channel_presence(channel, "unknown", (char *) state_names[state]);
} }
if (channel->state < CS_HANGUP) { if (state < CS_HANGUP) {
switch_event_t *event; switch_event_t *event;
if (switch_event_create(&event, SWITCH_EVENT_CHANNEL_STATE) == SWITCH_STATUS_SUCCESS) { if (switch_event_create(&event, SWITCH_EVENT_CHANNEL_STATE) == SWITCH_STATUS_SUCCESS) {
if (channel->state == CS_RING) { if (state == CS_RING) {
switch_channel_event_set_data(channel, event); switch_channel_event_set_data(channel, event);
} else { } else {
char state_num[25]; char state_num[25];
switch_snprintf(state_num, sizeof(state_num), "%d", channel->state); switch_snprintf(state_num, sizeof(state_num), "%d", state);
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Channel-State", "%s", (char *) switch_channel_state_name(channel->state)); switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Channel-State", "%s", (char *) switch_channel_state_name(state));
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Channel-State-Number", "%s", (char *) state_num); switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Channel-State-Number", "%s", (char *) state_num);
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Channel-Name", "%s", channel->name); switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Channel-Name", "%s", channel->name);
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Unique-ID", "%s", switch_core_session_get_uuid(channel->session)); switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Unique-ID", "%s", switch_core_session_get_uuid(channel->session));
@ -1013,12 +1013,9 @@ default:
} else { } else {
switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, NULL, SWITCH_LOG_WARNING, switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, NULL, SWITCH_LOG_WARNING,
"%s Invalid State Change %s -> %s\n", channel->name, state_names[last_state], state_names[state]); "%s Invalid State Change %s -> %s\n", channel->name, state_names[last_state], state_names[state]);
/* we won't tolerate an invalid state change so we can make sure we are as robust as a nice cup of dark coffee! */ /* we won't tolerate an invalid state change so we can make sure we are as robust as a nice cup of dark coffee! */
if (channel->state < CS_HANGUP) {
/* not cool lets crash this bad boy and figure out wtf is going on */ /* not cool lets crash this bad boy and figure out wtf is going on */
switch_assert(0); switch_assert(channel->state >= CS_HANGUP);
}
} }
done: done:

View File

@ -398,7 +398,7 @@ SWITCH_DECLARE(void) switch_core_session_run(switch_core_session_t *session)
int proceed = 1; int proceed = 1;
int do_extra_handlers = 1; int do_extra_handlers = 1;
switch_channel_set_running_state(session->channel); switch_channel_set_running_state(session->channel, state);
switch (state) { switch (state) {
case CS_NEW: /* Just created, Waiting for first instructions */ case CS_NEW: /* Just created, Waiting for first instructions */