]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
avoid scheduler caling a function on null hash during shutdown
authorAnthony Minessale <anthm@freeswitch.org>
Thu, 13 Jan 2011 16:30:29 +0000 (10:30 -0600)
committerAnthony Minessale <anthm@freeswitch.org>
Thu, 13 Jan 2011 16:30:29 +0000 (10:30 -0600)
src/mod/applications/mod_hash/mod_hash.c

index d03ff92765497877662c13ae6cb7f1c04a6e144c..e3f01cec960df57ca49bd2e3254f2bdd9829c4cc 100644 (file)
@@ -263,10 +263,14 @@ SWITCH_HASH_DELETE_FUNC(limit_hash_remote_cleanup_callback)
 SWITCH_STANDARD_SCHED_FUNC(limit_hash_cleanup_callback)
 {
        switch_thread_rwlock_wrlock(globals.limit_hash_rwlock);
-       switch_core_hash_delete_multi(globals.limit_hash, limit_hash_cleanup_delete_callback, NULL);
+       if (globals.limit_hash) {
+               switch_core_hash_delete_multi(globals.limit_hash, limit_hash_cleanup_delete_callback, NULL);
+       }
        switch_thread_rwlock_unlock(globals.limit_hash_rwlock);
-       
-       task->runtime = switch_epoch_time_now(NULL) + LIMIT_HASH_CLEANUP_INTERVAL;
+
+       if (globals.limit_hash) {       
+               task->runtime = switch_epoch_time_now(NULL) + LIMIT_HASH_CLEANUP_INTERVAL;
+       }
 }
 
 /* !\brief Releases usage of a limit_hash-controlled ressource  */
@@ -991,7 +995,9 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_hash_shutdown)
                free(val);
                switch_core_hash_delete(globals.db_hash, key);
        }
-       
+
+       switch_core_hash_destroy(&globals.limit_hash);
+       switch_core_hash_destroy(&globals.db_hash);     
 
        switch_thread_rwlock_unlock(globals.limit_hash_rwlock);
        switch_thread_rwlock_unlock(globals.db_hash_rwlock);
@@ -999,8 +1005,6 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_hash_shutdown)
        switch_thread_rwlock_destroy(globals.db_hash_rwlock);
        switch_thread_rwlock_destroy(globals.limit_hash_rwlock);
 
-       switch_core_hash_destroy(&globals.limit_hash);
-       switch_core_hash_destroy(&globals.db_hash);
 
        return SWITCH_STATUS_SUCCESS;
 }