[svn-commits] file: branch file/usecnt-cleanup r54524 - /team/file/usecnt-cleanup/main/

svn-commits at lists.digium.com svn-commits at lists.digium.com
Wed Feb 14 17:16:51 MST 2007


Author: file
Date: Wed Feb 14 18:16:50 2007
New Revision: 54524

URL: http://svn.digium.com/view/asterisk?view=rev&rev=54524
Log:
Add automatic unregistering for every module link possible (applications/dialplan functions/channel techs/etc).

Modified:
    team/file/usecnt-cleanup/main/cdr.c
    team/file/usecnt-cleanup/main/file.c
    team/file/usecnt-cleanup/main/loader.c

Modified: team/file/usecnt-cleanup/main/cdr.c
URL: http://svn.digium.com/view/asterisk/team/file/usecnt-cleanup/main/cdr.c?view=diff&rev=54524&r1=54523&r2=54524
==============================================================================
--- team/file/usecnt-cleanup/main/cdr.c (original)
+++ team/file/usecnt-cleanup/main/cdr.c Wed Feb 14 18:16:50 2007
@@ -138,7 +138,7 @@
 		return -1;
 
 	if (mod)
-		ast_module_link(mod, AST_MODULE_REGISTERED_CDR, i);
+		ast_module_link(mod, AST_MODULE_REGISTERED_CDR, (void*)name);
 	i->module = mod;
 	i->be = be;
 	ast_copy_string(i->name, name, sizeof(i->name));
@@ -160,7 +160,7 @@
 	AST_LIST_TRAVERSE_SAFE_BEGIN(&be_list, i, list) {
 		if (!strcasecmp(name, i->name)) {
 			if (i->module)
-				ast_module_unlink(i->module, AST_MODULE_REGISTERED_CDR, i);
+				ast_module_unlink(i->module, AST_MODULE_REGISTERED_CDR, (void*)name);
 			AST_LIST_REMOVE_CURRENT(&be_list, list);
 			if (option_verbose > 1)
 				ast_verbose(VERBOSE_PREFIX_2 "Unregistered '%s' CDR backend\n", name);

Modified: team/file/usecnt-cleanup/main/file.c
URL: http://svn.digium.com/view/asterisk/team/file/usecnt-cleanup/main/file.c?view=diff&rev=54524&r1=54523&r2=54524
==============================================================================
--- team/file/usecnt-cleanup/main/file.c (original)
+++ team/file/usecnt-cleanup/main/file.c Wed Feb 14 18:16:50 2007
@@ -83,7 +83,7 @@
 	}
 	*tmp = *f;
 	if (mod)
-		ast_module_link(mod, AST_MODULE_REGISTERED_FORMAT, tmp);
+		ast_module_link(mod, AST_MODULE_REGISTERED_FORMAT, (void*)f->name);
 	tmp->module = mod;
 	if (tmp->buf_size) {
 		/*
@@ -114,7 +114,7 @@
 	AST_RWLIST_TRAVERSE_SAFE_BEGIN(&formats, tmp, list) {
 		if (!strcasecmp(name, tmp->name)) {
 			if (tmp->module)
-				ast_module_unlink(tmp->module, AST_MODULE_REGISTERED_FORMAT, tmp);
+				ast_module_unlink(tmp->module, AST_MODULE_REGISTERED_FORMAT, (void*)name);
 			AST_RWLIST_REMOVE_CURRENT(&formats, list);
 			free(tmp);
 			res = 0;

Modified: team/file/usecnt-cleanup/main/loader.c
URL: http://svn.digium.com/view/asterisk/team/file/usecnt-cleanup/main/loader.c?view=diff&rev=54524&r1=54523&r2=54524
==============================================================================
--- team/file/usecnt-cleanup/main/loader.c (original)
+++ team/file/usecnt-cleanup/main/loader.c Wed Feb 14 18:16:50 2007
@@ -54,6 +54,8 @@
 #include "asterisk/pbx.h"
 
 #include "asterisk/cli.h"
+#include "asterisk/translate.h"
+#include "asterisk/file.h"
 
 #ifdef DLFCNCOMPAT
 #include "asterisk/dlfcn-compat.h"
@@ -491,6 +493,18 @@
 					ast_channel_unregister((const struct ast_channel_tech *)link->data);
 				else if (link->registered == AST_MODULE_REGISTERED_CLI)
 					res = ast_cli_unregister((struct ast_cli_entry*)link->data);
+				else if (link->registered == AST_MODULE_REGISTERED_SWITCH)
+					ast_unregister_switch((struct ast_switch*)link->data);
+				else if (link->registered == AST_MODULE_REGISTERED_CODEC)
+					res = ast_unregister_translator((struct ast_translator*)link->data);
+				else if (link->registered == AST_MODULE_REGISTERED_FORMAT)
+					res = ast_format_unregister((const char*)link->data);
+				else if (link->registered == AST_MODULE_REGISTERED_CDR)
+					ast_cdr_unregister((const char*)link->data);
+				else if (link->registered == AST_MODULE_REGISTERED_FORMAT)
+					res = ast_format_unregister((const char*)link->data);
+				else if (link->registered == AST_MODULE_REGISTERED_FUNCTION)
+					res = ast_custom_function_unregister((struct ast_custom_function*)link->data);
 				free(link);
 				/* Handle error from unregister process */
 			}



More information about the svn-commits mailing list