[Asterisk-code-review] res odbc: Allow unload at shutdown. (asterisk[master])

Kevin Harwell asteriskteam at digium.com
Thu Aug 16 17:48:01 CDT 2018


Kevin Harwell has submitted this change and it was merged. ( https://gerrit.asterisk.org/9876 )

Change subject: res_odbc: Allow unload at shutdown.
......................................................................

res_odbc: Allow unload at shutdown.

This makes it possible for REF_DEBUG to report no leaks when loading
res_odbc.

Change-Id: I1a3dea786bd6e7f4820a6dd5cbaa197fa783ce93
---
M res/res_odbc.c
1 file changed, 12 insertions(+), 4 deletions(-)

Approvals:
  George Joseph: Looks good to me, but someone else must approve
  Kevin Harwell: Looks good to me, approved; Approved for Submit



diff --git a/res/res_odbc.c b/res/res_odbc.c
index 3ee8cba..b4c1585 100644
--- a/res/res_odbc.c
+++ b/res/res_odbc.c
@@ -996,17 +996,25 @@
 
 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;
 }
 

-- 
To view, visit https://gerrit.asterisk.org/9876
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I1a3dea786bd6e7f4820a6dd5cbaa197fa783ce93
Gerrit-Change-Number: 9876
Gerrit-PatchSet: 1
Gerrit-Owner: Corey Farrell <git at cfware.com>
Gerrit-Reviewer: Corey Farrell <git at cfware.com>
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Jenkins2
Gerrit-Reviewer: Kevin Harwell <kharwell at digium.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20180816/68518303/attachment.html>


More information about the asterisk-code-review mailing list