[asterisk-commits] file: branch file/usecnt-cleanup r54145 - in /team/file/usecnt-cleanup: inclu...

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Mon Feb 12 17:56:50 MST 2007


Author: file
Date: Mon Feb 12 18:56:50 2007
New Revision: 54145

URL: http://svn.digium.com/view/asterisk?view=rev&rev=54145
Log:
Module reference counting on PBX switches is magically delicious (isn't that right Dwayne?)

Modified:
    team/file/usecnt-cleanup/include/asterisk/pbx.h
    team/file/usecnt-cleanup/main/pbx.c

Modified: team/file/usecnt-cleanup/include/asterisk/pbx.h
URL: http://svn.digium.com/view/asterisk/team/file/usecnt-cleanup/include/asterisk/pbx.h?view=diff&rev=54145&r1=54144&r2=54145
==============================================================================
--- team/file/usecnt-cleanup/include/asterisk/pbx.h (original)
+++ team/file/usecnt-cleanup/include/asterisk/pbx.h Mon Feb 12 18:56:50 2007
@@ -89,7 +89,7 @@
 	AST_LIST_ENTRY(ast_switch) list;
 	const char *name;			/*!< Name of the switch */
 	const char *description;		/*!< Description of the switch */
-	
+	struct ast_module *module;
 	ast_switch_f *exists;
 	ast_switch_f *canmatch;
 	ast_switch_f *exec;
@@ -123,7 +123,8 @@
  *
  * \return 0 on success, and other than 0 on failure
  */
-int ast_register_switch(struct ast_switch *sw);
+#define ast_register_switch(a) __ast_register_switch(a, ast_module_info->self)
+int __ast_register_switch(struct ast_switch *sw, struct ast_module *mod);
 
 /*!
  * \brief Unregister an alternative switch

Modified: team/file/usecnt-cleanup/main/pbx.c
URL: http://svn.digium.com/view/asterisk/team/file/usecnt-cleanup/main/pbx.c?view=diff&rev=54145&r1=54144&r2=54145
==============================================================================
--- team/file/usecnt-cleanup/main/pbx.c (original)
+++ team/file/usecnt-cleanup/main/pbx.c Mon Feb 12 18:56:50 2007
@@ -537,8 +537,11 @@
 
 	AST_RWLIST_RDLOCK(&switches);
 	AST_RWLIST_TRAVERSE(&switches, asw, list) {
-		if (!strcasecmp(asw->name, sw))
+		if (!strcasecmp(asw->name, sw)) {
+			if (asw->module)
+				ast_module_ref(asw->module);
 			break;
+		}
 	}
 	AST_RWLIST_UNLOCK(&switches);
 
@@ -1004,6 +1007,8 @@
 			aswf = asw->exists;
 		datap = sw->eval ? sw->tmpdata : sw->data;
 		res = !aswf ? 0 : aswf(chan, context, exten, priority, callerid, datap);
+		if (asw->module)
+			ast_module_unref(asw->module);
 		if (res) {	/* Got a match */
 			q->swo = asw;
 			q->data = datap;
@@ -2880,7 +2885,7 @@
  * Append to the list. We don't have a tail pointer because we need
  * to scan the list anyways to check for duplicates during insertion.
  */
-int ast_register_switch(struct ast_switch *sw)
+int __ast_register_switch(struct ast_switch *sw, struct ast_module *mod)
 {
 	struct ast_switch *tmp;
 
@@ -2892,6 +2897,7 @@
 			return -1;
 		}
 	}
+	sw->module = mod;
 	AST_RWLIST_INSERT_TAIL(&switches, sw, list);
 	AST_RWLIST_UNLOCK(&switches);
 



More information about the asterisk-commits mailing list