mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-04-15 08:29:45 +00:00
FS-6402 part 2
This commit is contained in:
parent
5110ee8008
commit
7151d6acea
@ -1459,7 +1459,15 @@ SWITCH_DECLARE(void *) switch_core_hash_find_rdlock(_In_ switch_hash_t *hash, _I
|
||||
\param hash the hashtable to use
|
||||
\return The element, or NULL if it wasn't found
|
||||
*/
|
||||
SWITCH_DECLARE(switch_hash_index_t *) switch_core_hash_first(_In_ switch_hash_t *hash);
|
||||
SWITCH_DECLARE(switch_hash_index_t *) switch_core_hash_first_iter(_In_ switch_hash_t *hash, switch_hash_index_t *hi);
|
||||
#define switch_core_hash_first(_h) switch_core_hash_first_iter(_h, NULL)
|
||||
|
||||
/*!
|
||||
\brief tells if a hash is empty
|
||||
\param hash the hashtable
|
||||
\return TRUE or FALSE depending on if the hash is empty
|
||||
*/
|
||||
SWITCH_DECLARE(switch_bool_t) switch_core_hash_empty(switch_hash_t *hash);
|
||||
|
||||
/*!
|
||||
\brief Gets the next element of a hashtable
|
||||
|
@ -190,7 +190,8 @@ switch_hashtable_count(switch_hashtable_t *h);
|
||||
SWITCH_DECLARE(void)
|
||||
switch_hashtable_destroy(switch_hashtable_t **h);
|
||||
|
||||
SWITCH_DECLARE(switch_hashtable_iterator_t*) switch_hashtable_first(switch_hashtable_t *h);
|
||||
SWITCH_DECLARE(switch_hashtable_iterator_t*) switch_hashtable_first_iter(switch_hashtable_t *h, switch_hashtable_iterator_t *it);
|
||||
#define switch_hashtable_first(_h) switch_hashtable_first_iter(_h, NULL)
|
||||
SWITCH_DECLARE(switch_hashtable_iterator_t*) switch_hashtable_next(switch_hashtable_iterator_t **iP);
|
||||
SWITCH_DECLARE(void) switch_hashtable_this(switch_hashtable_iterator_t *i, const void **key, switch_ssize_t *klen, void **val);
|
||||
|
||||
|
@ -116,7 +116,7 @@ static switch_status_t do_config(switch_bool_t reload)
|
||||
{
|
||||
/* Load up blacklists */
|
||||
switch_xml_t xml, cfg, lists, list;
|
||||
switch_hash_index_t *hi;
|
||||
switch_hash_index_t *hi = NULL;
|
||||
|
||||
if (!(xml = switch_xml_open_cfg("mod_blacklist.conf", &cfg, NULL))) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't load configuration section\n");
|
||||
@ -126,7 +126,7 @@ static switch_status_t do_config(switch_bool_t reload)
|
||||
switch_mutex_lock(globals.lists_mutex);
|
||||
|
||||
/* Destroy any active lists */
|
||||
while ((hi = switch_core_hash_first( globals.lists))) {
|
||||
while ((hi = switch_core_hash_first_iter( globals.lists, hi))) {
|
||||
const void *key;
|
||||
void *val;
|
||||
switch_core_hash_this(hi, &key, NULL, &val);
|
||||
|
@ -3373,7 +3373,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_callcenter_load)
|
||||
Macro expands to: switch_status_t mod_callcenter_shutdown() */
|
||||
SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_callcenter_shutdown)
|
||||
{
|
||||
switch_hash_index_t *hi;
|
||||
switch_hash_index_t *hi = NULL;
|
||||
cc_queue_t *queue;
|
||||
void *val = NULL;
|
||||
const void *key;
|
||||
@ -3394,7 +3394,7 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_callcenter_shutdown)
|
||||
}
|
||||
|
||||
switch_mutex_lock(globals.mutex);
|
||||
while ((hi = switch_core_hash_first( globals.queue_hash))) {
|
||||
while ((hi = switch_core_hash_first_iter( globals.queue_hash, hi))) {
|
||||
switch_core_hash_this(hi, &key, &keylen, &val);
|
||||
queue = (cc_queue_t *) val;
|
||||
|
||||
|
@ -1018,7 +1018,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_hash_load)
|
||||
|
||||
SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_hash_shutdown)
|
||||
{
|
||||
switch_hash_index_t *hi;
|
||||
switch_hash_index_t *hi = NULL;
|
||||
switch_bool_t remote_clean = SWITCH_TRUE;
|
||||
|
||||
switch_scheduler_del_task_group("mod_hash");
|
||||
@ -1050,7 +1050,7 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_hash_shutdown)
|
||||
switch_thread_rwlock_wrlock(globals.limit_hash_rwlock);
|
||||
switch_thread_rwlock_wrlock(globals.db_hash_rwlock);
|
||||
|
||||
while ((hi = switch_core_hash_first( globals.limit_hash))) {
|
||||
while ((hi = switch_core_hash_first_iter( globals.limit_hash, hi))) {
|
||||
void *val = NULL;
|
||||
const void *key;
|
||||
switch_ssize_t keylen;
|
||||
@ -1059,7 +1059,7 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_hash_shutdown)
|
||||
switch_core_hash_delete(globals.limit_hash, key);
|
||||
}
|
||||
|
||||
while ((hi = switch_core_hash_first( globals.db_hash))) {
|
||||
while ((hi = switch_core_hash_first_iter( globals.db_hash, hi))) {
|
||||
void *val = NULL;
|
||||
const void *key;
|
||||
switch_ssize_t keylen;
|
||||
|
@ -170,7 +170,7 @@ static void do_unload(void) {
|
||||
|
||||
switch_mutex_lock(MUTEX);
|
||||
|
||||
while ((hi = switch_core_hash_first( globals.translate_profiles))) {
|
||||
while ((hi = switch_core_hash_first_iter( globals.translate_profiles, hi))) {
|
||||
void *val = NULL;
|
||||
const void *key;
|
||||
switch_ssize_t keylen;
|
||||
|
@ -105,7 +105,7 @@ static void check_timeouts(void)
|
||||
valet_lot_t *lot;
|
||||
switch_console_callback_match_t *matches = NULL;
|
||||
switch_console_callback_match_node_t *m;
|
||||
switch_hash_index_t *i_hi;
|
||||
switch_hash_index_t *i_hi = NULL;
|
||||
const void *i_var;
|
||||
void *i_val;
|
||||
char *i_ext;
|
||||
@ -135,7 +135,7 @@ static void check_timeouts(void)
|
||||
|
||||
top:
|
||||
|
||||
for (i_hi = switch_core_hash_first( lot->hash); i_hi; i_hi = switch_core_hash_next(&i_hi)) {
|
||||
for (i_hi = switch_core_hash_first_iter( lot->hash, i_hi); i_hi; i_hi = switch_core_hash_next(&i_hi)) {
|
||||
switch_core_hash_this(i_hi, &i_var, NULL, &i_val);
|
||||
i_ext = (char *) i_var;
|
||||
token = (valet_token_t *) i_val;
|
||||
@ -146,6 +146,7 @@ static void check_timeouts(void)
|
||||
goto top;
|
||||
}
|
||||
}
|
||||
switch_safe_free(i_hi);
|
||||
|
||||
switch_mutex_unlock(lot->mutex);
|
||||
}
|
||||
|
@ -4029,6 +4029,7 @@ static void actual_message_query_handler(switch_event_t *event)
|
||||
break;
|
||||
}
|
||||
}
|
||||
switch_safe_free(hi);
|
||||
}
|
||||
|
||||
switch_safe_free(dup);
|
||||
@ -4966,6 +4967,7 @@ SWITCH_STANDARD_API(voicemail_api_function)
|
||||
break;
|
||||
}
|
||||
}
|
||||
switch_safe_free(index);
|
||||
switch_mutex_unlock(globals.mutex);
|
||||
}
|
||||
|
||||
@ -6237,7 +6239,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_voicemail_load)
|
||||
|
||||
SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_voicemail_shutdown)
|
||||
{
|
||||
switch_hash_index_t *hi;
|
||||
switch_hash_index_t *hi = NULL;
|
||||
vm_profile_t *profile;
|
||||
void *val = NULL;
|
||||
const void *key;
|
||||
@ -6261,7 +6263,7 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_voicemail_shutdown)
|
||||
}
|
||||
|
||||
switch_mutex_lock(globals.mutex);
|
||||
while ((hi = switch_core_hash_first( globals.profile_hash))) {
|
||||
while ((hi = switch_core_hash_first_iter( globals.profile_hash, hi))) {
|
||||
switch_core_hash_this(hi, &key, &keylen, &val);
|
||||
profile = (vm_profile_t *) val;
|
||||
|
||||
|
@ -2205,6 +2205,7 @@ static switch_status_t recog_channel_start(speech_channel_t *schannel)
|
||||
no_grammar_alone:
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "(%s) Grammar '%s' can only be used alone (not a URI list)\n", schannel->name, key);
|
||||
status = SWITCH_STATUS_FALSE;
|
||||
switch_safe_free(egk);
|
||||
goto done;
|
||||
}
|
||||
len = strlen(grammar->data);
|
||||
|
@ -818,7 +818,7 @@ switch_status_t rtmp_session_request(rtmp_profile_t *profile, rtmp_session_t **n
|
||||
|
||||
static void rtmp_garbage_colletor(void)
|
||||
{
|
||||
switch_hash_index_t *hi;
|
||||
switch_hash_index_t *hi = NULL;
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG1, "RTMP Garbage Collection\n");
|
||||
|
||||
@ -827,7 +827,7 @@ static void rtmp_garbage_colletor(void)
|
||||
|
||||
top:
|
||||
|
||||
for (hi = switch_core_hash_first( rtmp_globals.session_hash); hi; hi = switch_core_hash_next(&hi)) {
|
||||
for (hi = switch_core_hash_first_iter( rtmp_globals.session_hash, hi); hi; hi = switch_core_hash_next(&hi)) {
|
||||
void *val;
|
||||
const void *key;
|
||||
switch_ssize_t keylen;
|
||||
@ -842,6 +842,7 @@ static void rtmp_garbage_colletor(void)
|
||||
}
|
||||
}
|
||||
}
|
||||
switch_safe_free(hi);
|
||||
|
||||
switch_thread_rwlock_unlock(rtmp_globals.session_rwlock);
|
||||
}
|
||||
@ -1930,10 +1931,10 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_rtmp_load)
|
||||
|
||||
SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_rtmp_shutdown)
|
||||
{
|
||||
switch_hash_index_t *hi;
|
||||
switch_hash_index_t *hi = NULL;
|
||||
|
||||
switch_mutex_lock(rtmp_globals.mutex);
|
||||
while ((hi = switch_core_hash_first( rtmp_globals.profile_hash))) {
|
||||
while ((hi = switch_core_hash_first_iter( rtmp_globals.profile_hash, hi))) {
|
||||
void *val;
|
||||
const void *key;
|
||||
switch_ssize_t keylen;
|
||||
|
@ -210,6 +210,7 @@ skinny_profile_t *skinny_find_profile_by_domain(const char *domain_name)
|
||||
break;
|
||||
}
|
||||
}
|
||||
switch_safe_free(hi);
|
||||
switch_mutex_unlock(globals.mutex);
|
||||
|
||||
return profile;
|
||||
@ -2477,7 +2478,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_skinny_load)
|
||||
load_skinny_config();
|
||||
|
||||
/* at least one profile */
|
||||
if (!switch_core_hash_first( globals.profile_hash)) {
|
||||
if (switch_core_hash_empty( globals.profile_hash)) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No profile found!\n");
|
||||
return SWITCH_STATUS_TERM;
|
||||
}
|
||||
|
@ -7206,6 +7206,7 @@ nua_handle_t *sofia_global_nua_handle_by_replaces(sip_replaces_t *replaces)
|
||||
break;
|
||||
}
|
||||
}
|
||||
switch_safe_free(hi);
|
||||
}
|
||||
switch_mutex_unlock(mod_sofia_globals.hash_mutex);
|
||||
|
||||
|
@ -1101,7 +1101,7 @@ static int debounce_check(sofia_profile_t *profile, const char *user, const char
|
||||
void sofia_reg_close_handles(sofia_profile_t *profile)
|
||||
{
|
||||
nua_handle_t *nh = NULL;
|
||||
switch_hash_index_t *hi;
|
||||
switch_hash_index_t *hi = NULL;
|
||||
const void *var;
|
||||
void *val;
|
||||
|
||||
@ -1109,7 +1109,7 @@ void sofia_reg_close_handles(sofia_profile_t *profile)
|
||||
switch_mutex_lock(profile->flag_mutex);
|
||||
if (profile->reg_nh_hash) {
|
||||
top:
|
||||
for (hi = switch_core_hash_first( profile->reg_nh_hash); hi; hi = switch_core_hash_next(&hi)) {
|
||||
for (hi = switch_core_hash_first_iter( profile->reg_nh_hash, hi); hi; hi = switch_core_hash_next(&hi)) {
|
||||
switch_core_hash_this(hi, &var, NULL, &val);
|
||||
if ((nh = (nua_handle_t *) val)) {
|
||||
nua_handle_unref(nh);
|
||||
@ -1118,6 +1118,8 @@ void sofia_reg_close_handles(sofia_profile_t *profile)
|
||||
goto top;
|
||||
}
|
||||
}
|
||||
switch_safe_free(hi);
|
||||
|
||||
}
|
||||
switch_mutex_unlock(profile->flag_mutex);
|
||||
|
||||
@ -3163,6 +3165,7 @@ sofia_gateway_t *sofia_reg_find_gateway_by_realm__(const char *file, const char
|
||||
gateway = NULL;
|
||||
}
|
||||
}
|
||||
switch_safe_free(hi);
|
||||
|
||||
if (gateway) {
|
||||
if (!sofia_test_pflag(gateway->profile, PFLAG_RUNNING) || gateway->deleted) {
|
||||
|
@ -1154,6 +1154,7 @@ static switch_status_t handle_ref_tuple(listener_t *listener, erlang_msg * msg,
|
||||
break;
|
||||
}
|
||||
}
|
||||
switch_safe_free(iter);
|
||||
switch_thread_rwlock_unlock(listener->session_rwlock);
|
||||
|
||||
if (found) {
|
||||
|
@ -373,6 +373,7 @@ session_elem_t *find_session_elem_by_pid(listener_t *listener, erlang_pid *pid)
|
||||
break;
|
||||
}
|
||||
}
|
||||
switch_safe_free(iter);
|
||||
switch_thread_rwlock_unlock(listener->session_rwlock);
|
||||
|
||||
return session;
|
||||
|
@ -508,6 +508,7 @@ static void pause_when_offline(void)
|
||||
break;
|
||||
}
|
||||
}
|
||||
switch_safe_free(hi);
|
||||
|
||||
if (is_online) {
|
||||
resume_inbound_calling();
|
||||
|
@ -105,7 +105,7 @@ static void unsubscribe(const char *uuid, const char *signal_type, const char *j
|
||||
switch_log_printf(SWITCH_CHANNEL_UUID_LOG(uuid), SWITCH_LOG_DEBUG, "Unsubscribe %s => %s\n", signal_type, jid);
|
||||
|
||||
/* clean up hash if empty */
|
||||
if (!switch_core_hash_first(signal_subscribers)) {
|
||||
if (switch_core_hash_empty(signal_subscribers)) {
|
||||
switch_log_printf(SWITCH_CHANNEL_UUID_LOG(uuid), SWITCH_LOG_DEBUG, "Destroy %s subscriber hash\n", signal_type);
|
||||
switch_core_hash_destroy(&signal_subscribers);
|
||||
switch_core_hash_delete(globals.subscribers, key);
|
||||
|
@ -205,9 +205,22 @@ SWITCH_DECLARE(void *) switch_core_hash_find_rdlock(switch_hash_t *hash, const c
|
||||
return val;
|
||||
}
|
||||
|
||||
SWITCH_DECLARE(switch_hash_index_t *) switch_core_hash_first(switch_hash_t *hash)
|
||||
SWITCH_DECLARE(switch_bool_t) switch_core_hash_empty(switch_hash_t *hash)
|
||||
{
|
||||
return switch_hashtable_first(hash);
|
||||
switch_hash_index_t *hi = switch_core_hash_first(hash);
|
||||
|
||||
if (hi) {
|
||||
switch_safe_free(hi);
|
||||
return SWITCH_FALSE;
|
||||
}
|
||||
|
||||
return SWITCH_TRUE;
|
||||
|
||||
}
|
||||
|
||||
SWITCH_DECLARE(switch_hash_index_t *) switch_core_hash_first_iter(switch_hash_t *hash, switch_hash_index_t *hi)
|
||||
{
|
||||
return switch_hashtable_first_iter(hash, hi);
|
||||
}
|
||||
|
||||
SWITCH_DECLARE(switch_hash_index_t *) switch_core_hash_next(switch_hash_index_t **hi)
|
||||
|
@ -2686,14 +2686,14 @@ static uint32_t switch_event_channel_unsub_head(switch_event_channel_func_t func
|
||||
|
||||
static void unsub_all_switch_event_channel(void)
|
||||
{
|
||||
switch_hash_index_t *hi;
|
||||
switch_hash_index_t *hi = NULL;
|
||||
const void *var;
|
||||
void *val;
|
||||
switch_event_channel_sub_node_head_t *head;
|
||||
|
||||
switch_thread_rwlock_wrlock(event_channel_manager.rwlock);
|
||||
|
||||
while ((hi = switch_core_hash_first( event_channel_manager.perm_hash))) {
|
||||
while ((hi = switch_core_hash_first_iter( event_channel_manager.perm_hash, hi))) {
|
||||
switch_event_t *vals = NULL;
|
||||
switch_core_hash_this(hi, &var, NULL, &val);
|
||||
vals = (switch_event_t *) val;
|
||||
@ -2701,7 +2701,7 @@ static void unsub_all_switch_event_channel(void)
|
||||
switch_event_destroy(&vals);
|
||||
}
|
||||
|
||||
while ((hi = switch_core_hash_first( event_channel_manager.hash))) {
|
||||
while ((hi = switch_core_hash_first_iter( event_channel_manager.hash, hi))) {
|
||||
switch_core_hash_this(hi, NULL, NULL, &val);
|
||||
head = (switch_event_channel_sub_node_head_t *) val;
|
||||
switch_event_channel_unsub_head(NULL, head);
|
||||
|
@ -294,11 +294,16 @@ SWITCH_DECLARE(switch_hashtable_iterator_t *) switch_hashtable_next(switch_hasht
|
||||
return NULL;
|
||||
}
|
||||
|
||||
SWITCH_DECLARE(switch_hashtable_iterator_t *) switch_hashtable_first(switch_hashtable_t *h)
|
||||
SWITCH_DECLARE(switch_hashtable_iterator_t *) switch_hashtable_first_iter(switch_hashtable_t *h, switch_hashtable_iterator_t *it)
|
||||
{
|
||||
switch_hashtable_iterator_t *iterator;
|
||||
|
||||
if (it) {
|
||||
iterator = it;
|
||||
} else {
|
||||
switch_zmalloc(iterator, sizeof(*iterator));
|
||||
}
|
||||
|
||||
switch_assert(iterator);
|
||||
|
||||
iterator->pos = 0;
|
||||
|
@ -647,6 +647,7 @@ static switch_status_t do_chat_send(switch_event_t *message_event)
|
||||
}
|
||||
}
|
||||
}
|
||||
switch_safe_free(hi);
|
||||
switch_mutex_unlock(loadable_modules.mutex);
|
||||
}
|
||||
|
||||
@ -2218,6 +2219,7 @@ SWITCH_DECLARE(int) switch_loadable_module_get_codecs(const switch_codec_impleme
|
||||
break;
|
||||
}
|
||||
}
|
||||
switch_safe_free(hi);
|
||||
|
||||
switch_mutex_unlock(loadable_modules.mutex);
|
||||
|
||||
|
@ -1945,7 +1945,7 @@ SWITCH_DECLARE(void) switch_xml_merge_user(switch_xml_t user, switch_xml_t domai
|
||||
|
||||
SWITCH_DECLARE(uint32_t) switch_xml_clear_user_cache(const char *key, const char *user_name, const char *domain_name)
|
||||
{
|
||||
switch_hash_index_t *hi;
|
||||
switch_hash_index_t *hi = NULL;
|
||||
void *val;
|
||||
const void *var;
|
||||
char mega_key[1024];
|
||||
@ -1971,18 +1971,20 @@ SWITCH_DECLARE(uint32_t) switch_xml_clear_user_cache(const char *key, const char
|
||||
|
||||
} else {
|
||||
|
||||
while ((hi = switch_core_hash_first( CACHE_HASH))) {
|
||||
while ((hi = switch_core_hash_first_iter( CACHE_HASH, hi))) {
|
||||
switch_core_hash_this(hi, &var, NULL, &val);
|
||||
switch_xml_free(val);
|
||||
switch_core_hash_delete(CACHE_HASH, var);
|
||||
r++;
|
||||
}
|
||||
|
||||
while ((hi = switch_core_hash_first( CACHE_EXPIRES_HASH))) {
|
||||
while ((hi = switch_core_hash_first_iter( CACHE_EXPIRES_HASH, hi))) {
|
||||
switch_core_hash_this(hi, &var, NULL, &val);
|
||||
switch_safe_free(val);
|
||||
switch_core_hash_delete(CACHE_EXPIRES_HASH, var);
|
||||
}
|
||||
|
||||
switch_safe_free(hi);
|
||||
}
|
||||
|
||||
switch_mutex_unlock(CACHE_MUTEX);
|
||||
|
Loading…
x
Reference in New Issue
Block a user