From: Corey Farrell Date: Wed, 15 Aug 2018 16:31:00 +0000 (-0400) Subject: res_odbc: Allow unload at shutdown. X-Git-Tag: 16.1.0-rc1~169^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b3704827869577bca3b6f90f9ef3a9306290e2b7;p=thirdparty%2Fasterisk.git res_odbc: Allow unload at shutdown. This makes it possible for REF_DEBUG to report no leaks when loading res_odbc. Change-Id: I1a3dea786bd6e7f4820a6dd5cbaa197fa783ce93 --- diff --git a/res/res_odbc.c b/res/res_odbc.c index 3ee8cba74e..b4c1585993 100644 --- a/res/res_odbc.c +++ b/res/res_odbc.c @@ -996,17 +996,25 @@ static int reload(void) static int unload_module(void) { - /* Prohibit unloading */ - return -1; + ao2_cleanup(class_container); + ast_cli_unregister_multiple(cli_odbc, ARRAY_LEN(cli_odbc)); + + return 0; } static int load_module(void) { - if (!(class_container = ao2_container_alloc(1, null_hash_fn, ao2_match_by_addr))) + if (!(class_container = ao2_container_alloc(1, null_hash_fn, ao2_match_by_addr))) { return AST_MODULE_LOAD_DECLINE; - if (load_odbc_config() == -1) + } + + if (load_odbc_config() == -1) { return AST_MODULE_LOAD_DECLINE; + } + + ast_module_shutdown_ref(ast_module_info->self); ast_cli_register_multiple(cli_odbc, ARRAY_LEN(cli_odbc)); + return AST_MODULE_LOAD_SUCCESS; }