FS-4836 not quite

This commit is contained in:
Anthony Minessale committed 2012-11-15 13:14:08 -06:00
1 parent 73f022873b
commit 057861867e
5 files changed
+2 -50

No files matched your search

+2 -40
View File
@@ -129,7 +129,6 @@ struct switch_channel {
switch_mutex_t *dtmf_mutex;
switch_mutex_t *flag_mutex;
switch_mutex_t *state_mutex;
switch_mutex_t *thread_mutex;
switch_mutex_t *profile_mutex;
switch_core_session_t *session;
switch_channel_state_t state;
@@ -353,7 +352,6 @@ SWITCH_DECLARE(switch_status_t) switch_channel_alloc(switch_channel_t **channel,
switch_mutex_init(&(*channel)->dtmf_mutex, SWITCH_MUTEX_NESTED, pool);
switch_mutex_init(&(*channel)->flag_mutex, SWITCH_MUTEX_NESTED, pool);
switch_mutex_init(&(*channel)->state_mutex, SWITCH_MUTEX_NESTED, pool);
switch_mutex_init(&(*channel)->thread_mutex, SWITCH_MUTEX_NESTED, pool);
switch_mutex_init(&(*channel)->profile_mutex, SWITCH_MUTEX_NESTED, pool);
(*channel)->hangup_cause = SWITCH_CAUSE_NONE;
(*channel)->name = "";
@@ -1927,32 +1925,6 @@ SWITCH_DECLARE(switch_channel_state_t) switch_channel_name_state(const char *nam
return CS_DESTROY;
}
static inline void careful_set(switch_channel_t *channel, switch_channel_state_t *state, switch_channel_state_t val) {
if (switch_mutex_trylock(channel->thread_mutex)) {
*state = val;
switch_mutex_unlock(channel->thread_mutex);
} else {
switch_mutex_t *mutex = switch_core_session_get_mutex(channel->session);
int x = 0;
for (x = 0; x < 100; x++) {
if (switch_mutex_trylock(mutex) == SWITCH_STATUS_SUCCESS) {
*state = val;
switch_mutex_unlock(mutex);
break;
} else {
switch_cond_next();
}
}
if (x == 100) {
*state = val;
}
}
}
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)
{
@@ -1978,7 +1950,7 @@ SWITCH_DECLARE(switch_channel_state_t) switch_channel_perform_set_running_state(
switch_mutex_lock(channel->state_mutex);
careful_set(channel, &channel->running_state, state);
channel->running_state = state;
if (state <= CS_DESTROY) {
switch_event_t *event;
@@ -2246,7 +2218,7 @@ SWITCH_DECLARE(switch_channel_state_t) switch_channel_perform_set_state(switch_c
switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, switch_channel_get_uuid(channel), SWITCH_LOG_DEBUG, "(%s) State Change %s -> %s\n",
channel->name, state_names[last_state], state_names[state]);
careful_set(channel, &channel->state, state);
channel->state = state;
if (state == CS_HANGUP && !channel->hangup_cause) {
channel->hangup_cause = SWITCH_CAUSE_NORMAL_CLEARING;
@@ -2268,16 +2240,6 @@ SWITCH_DECLARE(switch_channel_state_t) switch_channel_perform_set_state(switch_c
return channel->state;
}
SWITCH_DECLARE(void) switch_channel_state_thread_lock(switch_channel_t *channel)
{
switch_mutex_lock(channel->thread_mutex);
}
SWITCH_DECLARE(void) switch_channel_state_thread_unlock(switch_channel_t *channel)
{
switch_mutex_unlock(channel->thread_mutex);
}
SWITCH_DECLARE(void) switch_channel_event_set_basic_data(switch_channel_t *channel, switch_event_t *event)
{
switch_caller_profile_t *caller_profile, *originator_caller_profile = NULL, *originatee_caller_profile = NULL;