]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
avoidance a different way
authorAnthony Minessale <anthm@freeswitch.org>
Fri, 16 Jul 2010 16:43:14 +0000 (11:43 -0500)
committerAnthony Minessale <anthm@freeswitch.org>
Fri, 16 Jul 2010 16:43:14 +0000 (11:43 -0500)
src/switch_channel.c

index 1557830a31a06b6a07ff106f32a81a198cb2be7d..e82af1e792b1414b9111dbc71e9c8c73b137e8bb 100644 (file)
@@ -1226,18 +1226,22 @@ SWITCH_DECLARE(char *) switch_channel_get_cap_string(switch_channel_t *channel)
 
 SWITCH_DECLARE(void) switch_channel_set_flag_value(switch_channel_t *channel, switch_channel_flag_t flag, uint32_t value)
 {
+       int HELD = 0;
+       
        switch_assert(channel);
        switch_assert(channel->flag_mutex);
 
        switch_mutex_lock(channel->flag_mutex);
        if (flag == CF_LEG_HOLDING && !channel->flags[flag] && channel->flags[CF_ANSWERED]) {
-               switch_mutex_unlock(channel->flag_mutex);
-               switch_channel_set_callstate(channel, CCS_HELD);
-               switch_mutex_lock(channel->flag_mutex);
+               HELD = 1;
        }
        channel->flags[flag] = value;
        switch_mutex_unlock(channel->flag_mutex);
 
+       if (HELD) {
+               switch_channel_set_callstate(channel, CCS_HELD);
+       }
+
        if (flag == CF_OUTBOUND) {
                switch_channel_set_variable(channel, "is_outbound", "true");
        }
@@ -1319,16 +1323,22 @@ SWITCH_DECLARE(void) switch_channel_set_state_flag(switch_channel_t *channel, sw
 
 SWITCH_DECLARE(void) switch_channel_clear_flag(switch_channel_t *channel, switch_channel_flag_t flag)
 {
+       int ACTIVE = 0;
+
        switch_assert(channel != NULL);
        switch_assert(channel->flag_mutex);
 
        switch_mutex_lock(channel->flag_mutex);
        if (flag == CF_LEG_HOLDING && channel->flags[flag] && channel->flags[CF_ANSWERED]) {
-               switch_channel_set_callstate(channel, CCS_ACTIVE);
+               ACTIVE = 1;
        }
        channel->flags[flag] = 0;
        switch_mutex_unlock(channel->flag_mutex);
 
+       if (ACTIVE) {
+               switch_channel_set_callstate(channel, CCS_ACTIVE);
+       }
+
        if (flag == CF_OUTBOUND) {
                switch_channel_set_variable(channel, "is_outbound", NULL);
        }