[Freeswitch-svn] [commit] r12191 - freeswitch/trunk/src
FreeSWITCH SVN
anthm at freeswitch.org
Fri Feb 20 10:31:08 PST 2009
Author: anthm
Date: Fri Feb 20 12:31:08 2009
New Revision: 12191
Log:
add separate mutex for state related methods
Modified:
freeswitch/trunk/src/switch_channel.c
Modified: freeswitch/trunk/src/switch_channel.c
==============================================================================
--- freeswitch/trunk/src/switch_channel.c (original)
+++ freeswitch/trunk/src/switch_channel.c Fri Feb 20 12:31:08 2009
@@ -112,6 +112,7 @@
switch_queue_t *dtmf_queue;
switch_mutex_t *dtmf_mutex;
switch_mutex_t *flag_mutex;
+ switch_mutex_t *state_mutex;
switch_mutex_t *profile_mutex;
switch_core_session_t *session;
switch_channel_state_t state;
@@ -224,6 +225,7 @@
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)->profile_mutex, SWITCH_MUTEX_NESTED, pool);
(*channel)->hangup_cause = SWITCH_CAUSE_NONE;
(*channel)->name = "";
@@ -845,9 +847,9 @@
switch_channel_state_t state;
switch_assert(channel != NULL);
- switch_mutex_lock(channel->flag_mutex);
+ switch_mutex_lock(channel->state_mutex);
state = channel->state;
- switch_mutex_unlock(channel->flag_mutex);
+ switch_mutex_unlock(channel->state_mutex);
return state;
}
@@ -857,9 +859,9 @@
switch_channel_state_t state;
switch_assert(channel != NULL);
- switch_mutex_lock(channel->flag_mutex);
+ switch_mutex_lock(channel->state_mutex);
state = channel->running_state;
- switch_mutex_unlock(channel->flag_mutex);
+ switch_mutex_unlock(channel->state_mutex);
return state;
}
@@ -926,7 +928,7 @@
const char *file, const char *func, int line)
{
int x;
- switch_mutex_lock(channel->flag_mutex);
+ switch_mutex_lock(channel->state_mutex);
switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, NULL, SWITCH_LOG_DEBUG, "(%s) Running State Change %s\n", channel->name, state_names[state]);
channel->running_state = state;
@@ -972,7 +974,7 @@
}
}
- switch_mutex_unlock(channel->flag_mutex);
+ switch_mutex_unlock(channel->state_mutex);
return SWITCH_STATUS_SUCCESS;
}
@@ -985,7 +987,7 @@
switch_assert(channel != NULL);
switch_assert(state <= CS_DONE);
- switch_mutex_lock(channel->flag_mutex);
+ switch_mutex_lock(channel->state_mutex);
last_state = channel->state;
switch_assert(last_state <= CS_DONE);
@@ -1165,9 +1167,9 @@
if (ok) {
switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, NULL, SWITCH_LOG_DEBUG, "(%s) State Change %s -> %s\n",
channel->name, state_names[last_state], state_names[state]);
- switch_mutex_lock(channel->flag_mutex);
+ switch_mutex_lock(channel->state_mutex);
channel->state = state;
- switch_mutex_unlock(channel->flag_mutex);
+ switch_mutex_unlock(channel->state_mutex);
if (state == CS_HANGUP && !channel->hangup_cause) {
channel->hangup_cause = SWITCH_CAUSE_NORMAL_CLEARING;
@@ -1185,7 +1187,7 @@
}
done:
- switch_mutex_unlock(channel->flag_mutex);
+ switch_mutex_unlock(channel->state_mutex);
return channel->state;
}
@@ -1444,7 +1446,7 @@
int x, index;
switch_assert(channel != NULL);
- switch_mutex_lock(channel->flag_mutex);
+ switch_mutex_lock(channel->state_mutex);
for (x = 0; x < SWITCH_MAX_STATE_HANDLERS; x++) {
if (channel->state_handlers[x] == state_handler) {
index = x;
@@ -1461,7 +1463,7 @@
channel->state_handlers[index] = state_handler;
end:
- switch_mutex_unlock(channel->flag_mutex);
+ switch_mutex_unlock(channel->state_mutex);
return index;
}
@@ -1475,9 +1477,9 @@
return NULL;
}
- switch_mutex_lock(channel->flag_mutex);
+ switch_mutex_lock(channel->state_mutex);
h = channel->state_handlers[index];
- switch_mutex_unlock(channel->flag_mutex);
+ switch_mutex_unlock(channel->state_mutex);
return h;
}
@@ -1489,7 +1491,7 @@
switch_assert(channel != NULL);
- switch_mutex_lock(channel->flag_mutex);
+ switch_mutex_lock(channel->state_mutex);
channel->state_handler_index = 0;
if (state_handler) {
@@ -1509,7 +1511,7 @@
}
}
- switch_mutex_unlock(channel->flag_mutex);
+ switch_mutex_unlock(channel->state_mutex);
}
SWITCH_DECLARE(void) switch_channel_set_caller_extension(switch_channel_t *channel, switch_caller_extension_t *caller_extension)
@@ -1541,7 +1543,7 @@
const char *file, const char *func, int line, switch_call_cause_t hangup_cause)
{
switch_assert(channel != NULL);
- switch_mutex_lock(channel->flag_mutex);
+ switch_mutex_lock(channel->state_mutex);
if (channel->caller_profile && channel->caller_profile->times && !channel->caller_profile->times->hungup) {
switch_mutex_lock(channel->profile_mutex);
@@ -1576,7 +1578,7 @@
}
- switch_mutex_unlock(channel->flag_mutex);
+ switch_mutex_unlock(channel->state_mutex);
return channel->state;
}
More information about the Freeswitch-svn
mailing list