[Asterisk-code-review] res smdi.c: Fix module ref counting and inverted test. (asterisk[13])

Richard Mudgett asteriskteam at digium.com
Tue Oct 2 17:08:39 CDT 2018


Richard Mudgett has uploaded this change for review. ( https://gerrit.asterisk.org/10379


Change subject: res_smdi.c: Fix module ref counting and inverted test.
......................................................................

res_smdi.c: Fix module ref counting and inverted test.

* We don't need to bump the module reference count for each SMDI listener
because the listeners are entirely controlled by the life of the module.
When the module is unloaded any active listeners are stopped before the
module is unloaded from memory.  Also the previous module refs had several
off-nominal paths that unbalanced the module ref count.

* Fixed the smdi_load() return code of 1 concerning the number of
listeners.  The test was inverted.

Change-Id: Ic288db51b58e395d6a2fc3847f77176c16988784
---
M res/res_smdi.c
1 file changed, 6 insertions(+), 4 deletions(-)



  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/79/10379/1

diff --git a/res/res_smdi.c b/res/res_smdi.c
index 8622da4..5f96a02 100644
--- a/res/res_smdi.c
+++ b/res/res_smdi.c
@@ -247,8 +247,6 @@
 	ast_cond_destroy(&iface->mwi_q_cond);
 
 	free(iface);
-
-	ast_module_unref(ast_module_info->self);
 }
 
 /*!
@@ -985,6 +983,11 @@
 		return 0;
 
 	new_ifaces = ao2_container_alloc_list(AO2_ALLOC_OPT_LOCK_MUTEX, 0, NULL, smdi_ifaces_cmp_fn);
+	if (!new_ifaces) {
+		ast_config_destroy(conf);
+		return -1;
+	}
+
 	for (v = ast_variable_browse(conf, "interfaces"); v; v = v->next) {
 		RAII_VAR(struct ast_smdi_interface *, iface, NULL, ao2_cleanup);
 
@@ -1115,7 +1118,6 @@
 			}
 
 			ao2_link(new_ifaces, iface);
-			ast_module_ref(ast_module_info->self);
 		} else {
 			ast_log(LOG_NOTICE, "Ignoring unknown option %s in %s\n", v->name, config_file);
 		}
@@ -1157,7 +1159,7 @@
 		return -1;
 	}
 
-	if (ao2_container_count(new_ifaces)) {
+	if (!ao2_container_count(new_ifaces)) {
 		res = 1;
 	}
 

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

Gerrit-Project: asterisk
Gerrit-Branch: 13
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic288db51b58e395d6a2fc3847f77176c16988784
Gerrit-Change-Number: 10379
Gerrit-PatchSet: 1
Gerrit-Owner: Richard Mudgett <rmudgett at digium.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20181002/ab116827/attachment.html>


More information about the asterisk-code-review mailing list