diff --git a/modules/debugger/debugger_api.c b/modules/debugger/debugger_api.c index 014d5be1640..f060b36acbc 100644 --- a/modules/debugger/debugger_api.c +++ b/modules/debugger/debugger_api.c @@ -1161,6 +1161,63 @@ int dbg_init_mod_levels(int dbg_mod_hash_size) return 0; } +/** + * + */ +int dbg_destroy_mod_levels() +{ + int i; + dbg_mod_level_t *itl = NULL; + dbg_mod_level_t *itlp = NULL; + + dbg_mod_facility_t *itf = NULL; + dbg_mod_facility_t *itfp = NULL; + + if (_dbg_mod_table_size <= 0) + return 0; + + if (_dbg_mod_table == NULL) + return 0; + + for (i = 0; i < _dbg_mod_table_size; i++) { + // destroy level list + lock_get(&_dbg_mod_table[i].lock); + itl = _dbg_mod_table[i].first; + while (itl) { + itlp = itl; + itl = itl->next; + shm_free(itlp); + } + lock_release(&_dbg_mod_table[i].lock); + + // destroy facility list + lock_get(&_dbg_mod_table[i].lock_ft); + itf = _dbg_mod_table[i].first_ft; + while (itf) { + itfp = itf; + itf = itf->next; + shm_free(itfp); + } + lock_release(&_dbg_mod_table[i].lock_ft); + + // destroy locks + lock_destroy(&_dbg_mod_table[i].lock); + lock_destroy(&_dbg_mod_table[i].lock_ft); + + // reset all + _dbg_mod_table[i].first = NULL; + _dbg_mod_table[i].first_ft = NULL; + } + + // free table + shm_free(_dbg_mod_table); + _dbg_mod_table = NULL; + + LM_DBG("Destroyed _dbg_mod_table, size %d\n", _dbg_mod_table_size); + + return 0; +} + /* * case insensitive hashing - clone here to avoid usage of LOG*() * - s1 - str to hash diff --git a/modules/debugger/debugger_api.h b/modules/debugger/debugger_api.h index e41b15ab03f..7d034c27bfd 100644 --- a/modules/debugger/debugger_api.h +++ b/modules/debugger/debugger_api.h @@ -34,6 +34,7 @@ int dbg_init_mypid(void); int dbg_init_rpc(void); int dbg_init_mod_levels(int _dbg_mod_hash_size); +int dbg_destroy_mod_levels(); int dbg_set_mod_debug_level(char *mname, int mnlen, int *mlevel); int dbg_set_mod_debug_facility(char *mname, int mnlen, int *mfacility); void dbg_enable_mod_levels(void); diff --git a/modules/debugger/debugger_mod.c b/modules/debugger/debugger_mod.c index e77982591c2..e37ab83a5f0 100644 --- a/modules/debugger/debugger_mod.c +++ b/modules/debugger/debugger_mod.c @@ -507,6 +507,7 @@ static int child_init(int rank) static void mod_destroy(void) { dbg_cfg = NULL; + dbg_destroy_mod_levels(); } /**