From: Mathieu Rene Date: Tue, 13 Jul 2010 23:04:41 +0000 (-0400) Subject: mod_hash: free all hashtables on shutdown X-Git-Tag: v1.2-rc1~544^2~47 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e76d7d925ea6ffc804e1971b1e2a178f63513669;p=thirdparty%2Ffreeswitch.git mod_hash: free all hashtables on shutdown --- diff --git a/src/mod/applications/mod_hash/mod_hash.c b/src/mod/applications/mod_hash/mod_hash.c index eb02e5104a..8179690928 100644 --- a/src/mod/applications/mod_hash/mod_hash.c +++ b/src/mod/applications/mod_hash/mod_hash.c @@ -486,8 +486,35 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_hash_load) SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_hash_shutdown) { + switch_hash_index_t *hi = NULL; + switch_scheduler_del_task_group("mod_hash"); + switch_thread_rwlock_wrlock(globals.limit_hash_rwlock); + switch_thread_rwlock_wrlock(globals.db_hash_rwlock); + + while ((hi = switch_hash_first(NULL, globals.limit_hash))) { + void *val = NULL; + const void *key; + switch_ssize_t keylen; + switch_hash_this(hi, &key, &keylen, &val); + free(val); + switch_core_hash_delete(globals.limit_hash, key); + } + + while ((hi = switch_hash_first(NULL, globals.db_hash))) { + void *val = NULL; + const void *key; + switch_ssize_t keylen; + switch_hash_this(hi, &key, &keylen, &val); + free(val); + switch_core_hash_delete(globals.db_hash, key); + } + + + switch_thread_rwlock_unlock(globals.limit_hash_rwlock); + switch_thread_rwlock_unlock(globals.db_hash_rwlock); + switch_thread_rwlock_destroy(globals.db_hash_rwlock); switch_thread_rwlock_destroy(globals.limit_hash_rwlock);