]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
fix logic in app flags
authorAnthony Minessale <anthm@freeswitch.org>
Wed, 15 Sep 2010 23:57:54 +0000 (18:57 -0500)
committerAnthony Minessale <anthm@freeswitch.org>
Wed, 15 Sep 2010 23:57:54 +0000 (18:57 -0500)
src/switch_channel.c

index e3d77d72392a0958894342a67f864bbf02a0e009..ba5560129bd6abd5888cdca6dc3bba9df66674af 100644 (file)
@@ -1291,19 +1291,24 @@ SWITCH_DECLARE(int) switch_channel_test_private_flag(switch_channel_t *channel,
 SWITCH_DECLARE(void) switch_channel_set_app_flag_key(const char *key, switch_channel_t *channel, uint32_t flags)
 {
        uint32_t *flagp = NULL;
-       
+       switch_byte_t new = 0;
+
        switch_assert(channel != NULL);
        switch_mutex_lock(channel->flag_mutex);
-       
-       if (channel->app_flag_hash) {
-               flagp = switch_core_hash_find(channel->app_flag_hash, key);
-       } else {
+
+       if (!channel->app_flag_hash) {
                switch_core_hash_init(&channel->app_flag_hash, switch_core_session_get_pool(channel->session));
+               new++;
+       }
+       
+       if (new || !(flagp = switch_core_hash_find(channel->app_flag_hash, key))) {
                flagp = switch_core_session_alloc(channel->session, sizeof(uint32_t));
                switch_core_hash_insert(channel->app_flag_hash, key, flagp);
        }
 
-       if (flagp) *flagp |= flags;
+       switch_assert(flagp);
+       *flagp |= flags;
+
        switch_mutex_unlock(channel->flag_mutex);
 }