]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
mod_hash: free all hashtables on shutdown
authorMathieu Rene <mrene@avgs.ca>
Tue, 13 Jul 2010 23:04:41 +0000 (19:04 -0400)
committerMathieu Rene <mrene@avgs.ca>
Tue, 13 Jul 2010 23:05:07 +0000 (19:05 -0400)
src/mod/applications/mod_hash/mod_hash.c

index eb02e5104a01e01fb9b7045e5d490b4004756aee..8179690928160c24923351262ef88287c0830679 100644 (file)
@@ -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);