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

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


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


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/80/10380/1

diff --git a/res/res_smdi.c b/res/res_smdi.c
index 76e70c2..38e134c 100644
--- a/res/res_smdi.c
+++ b/res/res_smdi.c
@@ -245,8 +245,6 @@
 	ast_cond_destroy(&iface->mwi_q_cond);
 
 	ast_free(iface);
-
-	ast_module_unref(ast_module_info->self);
 }
 
 /*!
@@ -983,6 +981,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);
 
@@ -1113,7 +1116,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);
 		}
@@ -1155,7 +1157,7 @@
 		return -1;
 	}
 
-	if (ao2_container_count(new_ifaces)) {
+	if (!ao2_container_count(new_ifaces)) {
 		res = 1;
 	}
 

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

Gerrit-Project: asterisk
Gerrit-Branch: 15
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic288db51b58e395d6a2fc3847f77176c16988784
Gerrit-Change-Number: 10380
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/5841a51d/attachment-0001.html>


More information about the asterisk-code-review mailing list