fix logic in app flags
This commit is contained in:
parent
3eb35a57bf
commit
4e567a28a2
|
@ -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)
|
SWITCH_DECLARE(void) switch_channel_set_app_flag_key(const char *key, switch_channel_t *channel, uint32_t flags)
|
||||||
{
|
{
|
||||||
uint32_t *flagp = NULL;
|
uint32_t *flagp = NULL;
|
||||||
|
switch_byte_t new = 0;
|
||||||
|
|
||||||
switch_assert(channel != NULL);
|
switch_assert(channel != NULL);
|
||||||
switch_mutex_lock(channel->flag_mutex);
|
switch_mutex_lock(channel->flag_mutex);
|
||||||
|
|
||||||
if (channel->app_flag_hash) {
|
if (!channel->app_flag_hash) {
|
||||||
flagp = switch_core_hash_find(channel->app_flag_hash, key);
|
|
||||||
} else {
|
|
||||||
switch_core_hash_init(&channel->app_flag_hash, switch_core_session_get_pool(channel->session));
|
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));
|
flagp = switch_core_session_alloc(channel->session, sizeof(uint32_t));
|
||||||
switch_core_hash_insert(channel->app_flag_hash, key, flagp);
|
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);
|
switch_mutex_unlock(channel->flag_mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue