[asterisk-commits] branch group/new_loader_completion r21100 - in /team/group/new_loader_complet...

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Tue Apr 18 06:49:54 MST 2006


Author: kpfleming
Date: Tue Apr 18 08:49:50 2006
New Revision: 21100

URL: http://svn.digium.com/view/asterisk?rev=21100&view=rev
Log:
various cleanups and simplifications... getting closer now

Modified:
    team/group/new_loader_completion/cli.c
    team/group/new_loader_completion/file.c
    team/group/new_loader_completion/include/asterisk/module.h
    team/group/new_loader_completion/loader.c
    team/group/new_loader_completion/res/res_adsi.c
    team/group/new_loader_completion/res/res_agi.c
    team/group/new_loader_completion/res/res_clioriginate.c
    team/group/new_loader_completion/res/res_config_odbc.c
    team/group/new_loader_completion/res/res_config_pgsql.c
    team/group/new_loader_completion/res/res_convert.c
    team/group/new_loader_completion/res/res_crypto.c
    team/group/new_loader_completion/translate.c

Modified: team/group/new_loader_completion/cli.c
URL: http://svn.digium.com/view/asterisk/team/group/new_loader_completion/cli.c?rev=21100&r1=21099&r2=21100&view=diff
==============================================================================
--- team/group/new_loader_completion/cli.c (original)
+++ team/group/new_loader_completion/cli.c Tue Apr 18 08:49:50 2006
@@ -40,11 +40,7 @@
 #include "asterisk/options.h"
 #include "asterisk/cli.h"
 #include "asterisk/linkedlists.h"
-
-#define	NOT_A_MODULE
 #include "asterisk/module.h"
-#undef NOT_A_MODULE
-
 #include "asterisk/pbx.h"
 #include "asterisk/channel.h"
 #include "asterisk/manager.h"

Modified: team/group/new_loader_completion/file.c
URL: http://svn.digium.com/view/asterisk/team/group/new_loader_completion/file.c?rev=21100&r1=21099&r2=21100&view=diff
==============================================================================
--- team/group/new_loader_completion/file.c (original)
+++ team/group/new_loader_completion/file.c Tue Apr 18 08:49:50 2006
@@ -51,10 +51,7 @@
 #include "asterisk/app.h"
 #include "asterisk/pbx.h"
 #include "asterisk/linkedlists.h"
-
-#define NOT_A_MODULE
 #include "asterisk/module.h"
-#undef NOT_A_MODULE
 
 /*
  * The following variable controls the layout of localized sound files.

Modified: team/group/new_loader_completion/include/asterisk/module.h
URL: http://svn.digium.com/view/asterisk/team/group/new_loader_completion/include/asterisk/module.h?rev=21100&r1=21099&r2=21100&view=diff
==============================================================================
--- team/group/new_loader_completion/include/asterisk/module.h (original)
+++ team/group/new_loader_completion/include/asterisk/module.h Tue Apr 18 08:49:50 2006
@@ -285,13 +285,9 @@
    other macros that need to identify the module.
 */
 
-#ifndef NOT_A_MODULE
-static struct ast_module *__module_self;
-#endif /* !NOT_A_MODULE */
-
 struct ast_module_info {
 
-	struct ast_module **self;
+	struct ast_module *self;
 
 	int (*load)(void);	/* register stuff etc. Optional. */
 
@@ -320,26 +316,30 @@
 void __ast_module_user_remove(struct ast_module *, struct ast_module_user *);
 void __ast_module_user_hangup_all(struct ast_module *);
 
-#define ast_module_user_add(chan) __ast_module_user_add(__module_self, chan)
-#define ast_module_user_remove(user) __ast_module_user_remove(__module_self, user)
-#define ast_module_user_hangup_all() __ast_module_user_hangup_all(__module_self)
+#define ast_module_user_add(chan) __ast_module_user_add(ast_module_info.self, chan)
+#define ast_module_user_remove(user) __ast_module_user_remove(ast_module_info.self, user)
+#define ast_module_user_hangup_all() __ast_module_user_hangup_all(ast_module_info.self)
 
 struct ast_module *ast_module_ref(struct ast_module *);
 void ast_module_unref(struct ast_module *);
 
-#define AST_MODULE_INFO(desc, keystr, flags_to_set, fields...)		\
+/* forward declare this structure in modules, so that macro/function
+   calls that need it can get it, since it will actually be declared
+   and populated at the end of the module's source file */
+const struct ast_module_info ast_module_info;
+
+#define AST_MODULE_INFO(keystr, flags_to_set, desc, fields...)	\
 	const struct ast_module_info ast_module_info = {	\
-		.self = &__module_self,				\
 		.flags = { flags_to_set },			\
 		.description = desc,				\
 		.key = keystr,					\
 		fields						\
 	}
 
-#define AST_MODULE_INFO_STANDARD(desc, keystr)		\
-	AST_MODULE_INFO(desc, keystr, AST_MODULE_DEFAULT,	\
+#define AST_MODULE_INFO_STANDARD(keystr, desc)		\
+	AST_MODULE_INFO(keystr, AST_MODULE_DEFAULT, desc,	\
 			.load = load_module,			\
-			.unload = unload_module,			\
+			.unload = unload_module,		\
 		       )
 
 #if defined(__cplusplus) || defined(c_plusplus)

Modified: team/group/new_loader_completion/loader.c
URL: http://svn.digium.com/view/asterisk/team/group/new_loader_completion/loader.c?rev=21100&r1=21099&r2=21100&view=diff
==============================================================================
--- team/group/new_loader_completion/loader.c (original)
+++ team/group/new_loader_completion/loader.c Tue Apr 18 08:49:50 2006
@@ -39,11 +39,7 @@
 ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
 
 #include "asterisk/linkedlists.h"
-
-#define NOT_A_MODULE
 #include "asterisk/module.h"
-#undef NOT_A_MODULE
-
 #include "asterisk/options.h"
 #include "asterisk/config.h"
 #include "asterisk/logger.h"
@@ -74,7 +70,7 @@
 	AST_LIST_ENTRY(ast_module_user) entry;
 };
 
-AST_LIST_HEAD_NOLOCK(ast_module_user_list, ast_module_user);
+AST_LIST_HEAD(ast_module_user_list, ast_module_user);
 
 static unsigned int modlistver = 0; /* increase whenever the list changes, to protect reload */
 
@@ -109,9 +105,9 @@
  *
  * A second lock, reloadlock, is used to prevent concurrent reloads
  */
+
 struct ast_module {
 	const struct ast_module_info *mod;
-	ast_mutex_t lock;				/* protects usecount, export_refcount and users */
 	void *lib;					/* the shared lib */
 
 	enum st_t state;
@@ -147,9 +143,9 @@
 		return NULL;
 
 	u->chan = chan;
-	ast_mutex_lock(&mod->lock);
+	AST_LIST_LOCK(&mod->users);
 	AST_LIST_INSERT_HEAD(&mod->users, u, entry);
-	ast_mutex_unlock(&mod->lock);
+	AST_LIST_UNLOCK(&mod->users);
 	ast_atomic_fetchadd_int(&mod->usecount, +1);
 
 	ast_update_use_count();
@@ -159,9 +155,9 @@
 
 void __ast_module_user_remove(struct ast_module *mod, struct ast_module_user *u)
 {
-	ast_mutex_lock(&mod->lock);
+	AST_LIST_LOCK(&mod->users);
 	AST_LIST_REMOVE(&mod->users, u, entry);
-	ast_mutex_unlock(&mod->lock);
+	AST_LIST_UNLOCK(&mod->users);
 	ast_atomic_fetchadd_int(&mod->usecount, -1);
 	free(u);
 
@@ -172,13 +168,13 @@
 {
 	struct ast_module_user *u;
 
-	ast_mutex_lock(&mod->lock);
+	AST_LIST_LOCK(&mod->users);
 	while ((u = AST_LIST_REMOVE_HEAD(&mod->users, entry))) {
 		ast_softhangup(u->chan, AST_SOFTHANGUP_APPUNLOAD);
 		ast_atomic_fetchadd_int(&mod->usecount, -1);
 		free(u);
 	}
-	ast_mutex_unlock(&mod->lock);
+	AST_LIST_UNLOCK(&mod->users);
 
         ast_update_use_count();
 }
@@ -476,7 +472,7 @@
 	int x, pos;
 	char buf[256]; /* large enough so we don't have to worry */
 
-	for (pos = 0, x=0; x<16; x++)
+	for (pos = 0, x = 0; x < 16; x++)
 		pos += sprintf(buf + pos, " %02x", *d++);
 	ast_log(LOG_DEBUG, "Unexpected signature:%s\n", buf);
 
@@ -487,7 +483,7 @@
 {
 	int x;
 
-	for (x=0; x<16; x++) {
+	for (x = 0; x < 16; x++) {
 		if (key1[x] != key2[x])	/* mismatch - fail now. */
 			return 0;
 	}
@@ -517,7 +513,7 @@
 	while ((u = AST_LIST_REMOVE_HEAD(&mod->users, entry)))
 		free(u);
 	
-	ast_mutex_destroy(&mod->lock);
+	AST_LIST_HEAD_DESTROY(&mod->users);
 	free(mod);
 }
 
@@ -662,12 +658,14 @@
 {
 	struct ast_module *cur;
 
-	if (do_lock && AST_LIST_LOCK(&module_list))
-		ast_log(LOG_WARNING, "Failed to lock\n");
+	if (do_lock)
+		AST_LIST_LOCK(&module_list);
+
 	AST_LIST_TRAVERSE(&module_list, cur, entry) {
 		if (!strcasecmp(resource, cur->resource))
 			break;
 	}
+
 	if (do_lock)
 		AST_LIST_UNLOCK(&module_list);
 
@@ -762,8 +760,7 @@
 	}
 
 	/* init mutex and user list */
-	ast_mutex_init(&cur->lock);
-	AST_LIST_HEAD_INIT_NOLOCK(&cur->users);
+	AST_LIST_HEAD_INIT(&cur->users);
 
 	if (!ast_fully_booted) {
 		if (option_verbose) 
@@ -784,7 +781,7 @@
 	cur->state = MS_NEW;
 
 	/* give the module a copy of its own handle, for later use in registrations and the like */
-	*(m->self) = cur;
+	*((struct ast_module **) &(m->self)) = cur;
 
 	ast_update_use_count();
 

Modified: team/group/new_loader_completion/res/res_adsi.c
URL: http://svn.digium.com/view/asterisk/team/group/new_loader_completion/res/res_adsi.c?rev=21100&r1=21099&r2=21100&view=diff
==============================================================================
--- team/group/new_loader_completion/res/res_adsi.c (original)
+++ team/group/new_loader_completion/res/res_adsi.c Tue Apr 18 08:49:50 2006
@@ -1125,7 +1125,7 @@
 	return -1;
 }
 
-AST_MODULE_INFO("ADSI Resource", ASTERISK_GPL_KEY, AST_MODULE_DEFAULT,
+AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODULE_DEFAULT, "ADSI Resource",
 		.load = load_module,
 		.unload = unload_module,
 		.reload = reload,

Modified: team/group/new_loader_completion/res/res_agi.c
URL: http://svn.digium.com/view/asterisk/team/group/new_loader_completion/res/res_agi.c?rev=21100&r1=21099&r2=21100&view=diff
==============================================================================
--- team/group/new_loader_completion/res/res_agi.c (original)
+++ team/group/new_loader_completion/res/res_agi.c Tue Apr 18 08:49:50 2006
@@ -2048,4 +2048,4 @@
 	return ast_register_application(app, agi_exec, synopsis, descrip);
 }
 
-AST_MODULE_INFO_STANDARD("Asterisk Gateway Interface (AGI)", ASTERISK_GPL_KEY);
+AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Asterisk Gateway Interface (AGI)");

Modified: team/group/new_loader_completion/res/res_clioriginate.c
URL: http://svn.digium.com/view/asterisk/team/group/new_loader_completion/res/res_clioriginate.c?rev=21100&r1=21099&r2=21100&view=diff
==============================================================================
--- team/group/new_loader_completion/res/res_clioriginate.c (original)
+++ team/group/new_loader_completion/res/res_clioriginate.c Tue Apr 18 08:49:50 2006
@@ -131,7 +131,7 @@
 		return RESULT_SHOWUSAGE;
 
 	/* ugly, can be removed when CLI entries have ast_module pointers */
-	ast_module_ref(__module_self);
+	ast_module_ref(ast_module_info.self);
 
 	if (!strcasecmp("application", argv[2])) {
 		res = orig_app(argv[1], argv[3], argv[4]);	
@@ -140,7 +140,7 @@
 	} else
 		res = RESULT_SHOWUSAGE;
 
-	ast_module_unref(__module_self);
+	ast_module_unref(ast_module_info.self);
 
 	return res;
 }
@@ -154,9 +154,9 @@
 		return NULL;
 
 	/* ugly, can be removed when CLI entries have ast_module pointers */
-	ast_module_ref(__module_self);
+	ast_module_ref(ast_module_info.self);
 	ret = ast_cli_complete(word, choices, state);
-	ast_module_unref(__module_self);
+	ast_module_unref(ast_module_info.self);
 
 	return ret;
 }
@@ -171,4 +171,4 @@
 	return ast_cli_register(&cli_orig);
 }
 
-AST_MODULE_INFO_STANDARD("Call origination from the CLI", ASTERISK_GPL_KEY);
+AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Call origination from the CLI");

Modified: team/group/new_loader_completion/res/res_config_odbc.c
URL: http://svn.digium.com/view/asterisk/team/group/new_loader_completion/res/res_config_odbc.c?rev=21100&r1=21099&r2=21100&view=diff
==============================================================================
--- team/group/new_loader_completion/res/res_config_odbc.c (original)
+++ team/group/new_loader_completion/res/res_config_odbc.c Tue Apr 18 08:49:50 2006
@@ -521,4 +521,4 @@
 	return 0;
 }
 
-AST_MODULE_INFO_STANDARD("ODBC Configuration", ASTERISK_GPL_KEY);
+AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "ODBC Configuration");

Modified: team/group/new_loader_completion/res/res_config_pgsql.c
URL: http://svn.digium.com/view/asterisk/team/group/new_loader_completion/res/res_config_pgsql.c?rev=21100&r1=21099&r2=21100&view=diff
==============================================================================
--- team/group/new_loader_completion/res/res_config_pgsql.c (original)
+++ team/group/new_loader_completion/res/res_config_pgsql.c Tue Apr 18 08:49:50 2006
@@ -690,7 +690,7 @@
 }
 
 /* needs usecount semantics defined */
-AST_MODULE_INFO("Postgresql RealTime Configuration Driver", ASTERISK_GPL_KEY, AST_MODULE_DEFAULT,
+AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODULE_DEFAULT, "Postgresql RealTime Configuration Driver",
 		.load = load_module,
 		.unload = unload_module,
 		.reload = reload

Modified: team/group/new_loader_completion/res/res_convert.c
URL: http://svn.digium.com/view/asterisk/team/group/new_loader_completion/res/res_convert.c?rev=21100&r1=21099&r2=21100&view=diff
==============================================================================
--- team/group/new_loader_completion/res/res_convert.c (original)
+++ team/group/new_loader_completion/res/res_convert.c Tue Apr 18 08:49:50 2006
@@ -64,7 +64,7 @@
 	char *name_in, *ext_in, *name_out, *ext_out;
 	
 	/* ugly, can be removed when CLI entries have ast_module pointers */
-	ast_module_ref(__module_self);
+	ast_module_ref(ast_module_info.self);
 
 	if (argc != 3 || ast_strlen_zero(argv[1]) || ast_strlen_zero(argv[2])) {
 		ret = RESULT_SHOWUSAGE;
@@ -115,7 +115,7 @@
 	if (fs_in) 
 		ast_closestream(fs_in);
 
-	ast_module_unref(__module_self);
+	ast_module_unref(ast_module_info.self);
 
 	return ret;
 }
@@ -141,4 +141,4 @@
 	return ast_cli_register(&audio_convert_cli);
 }
 
-AST_MODULE_INFO_STANDARD("File format conversion CLI command", ASTERISK_GPL_KEY);
+AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "File format conversion CLI command");

Modified: team/group/new_loader_completion/res/res_crypto.c
URL: http://svn.digium.com/view/asterisk/team/group/new_loader_completion/res/res_crypto.c?rev=21100&r1=21099&r2=21100&view=diff
==============================================================================
--- team/group/new_loader_completion/res/res_crypto.c (original)
+++ team/group/new_loader_completion/res/res_crypto.c Tue Apr 18 08:49:50 2006
@@ -604,7 +604,7 @@
 }
 
 /* needs usecount semantics defined */
-AST_MODULE_INFO("Cryptographic Digital Signatures", ASTERISK_GPL_KEY, AST_MODULE_DEFAULT,
+AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODULE_DEFAULT, "Cryptographic Digital Signatures",
 		.load = load_module,
 		.unload = unload_module,
 		.reload = reload

Modified: team/group/new_loader_completion/translate.c
URL: http://svn.digium.com/view/asterisk/team/group/new_loader_completion/translate.c?rev=21100&r1=21099&r2=21100&view=diff
==============================================================================
--- team/group/new_loader_completion/translate.c (original)
+++ team/group/new_loader_completion/translate.c Tue Apr 18 08:49:50 2006
@@ -39,11 +39,7 @@
 #include "asterisk/channel.h"
 #include "asterisk/logger.h"
 #include "asterisk/translate.h"
-
-#define NOT_A_MODULE
 #include "asterisk/module.h"
-#undef NOT_A_MODULE
-
 #include "asterisk/options.h"
 #include "asterisk/frame.h"
 #include "asterisk/sched.h"



More information about the asterisk-commits mailing list