mirror of
				https://github.com/asterisk/asterisk.git
				synced 2025-10-31 02:37:10 +00:00 
			
		
		
		
	Merge "core: Remove embedded module support"
This commit is contained in:
		| @@ -11,7 +11,7 @@ | ||||
| # the GNU General Public License | ||||
| # | ||||
|  | ||||
| -include $(ASTTOPDIR)/menuselect.makeopts $(ASTTOPDIR)/menuselect.makedeps $(ASTTOPDIR)/makeopts.embed_rules $(ASTTOPDIR)/makeopts | ||||
| -include $(ASTTOPDIR)/menuselect.makeopts $(ASTTOPDIR)/menuselect.makedeps $(ASTTOPDIR)/makeopts | ||||
|  | ||||
| all: asterisk | ||||
|  | ||||
| @@ -48,9 +48,7 @@ AST_LIBS+=$(RT_LIB) | ||||
| AST_LIBS+=$(SYSTEMD_LIB) | ||||
|  | ||||
| ifneq ($(findstring $(OSARCH), linux-gnu uclinux linux-uclibc linux-musl kfreebsd-gnu),) | ||||
|   ifneq ($(findstring LOADABLE_MODULES,$(MENUSELECT_CFLAGS)),) | ||||
|   AST_LIBS+=-ldl | ||||
|   endif | ||||
|   ifneq (x$(CAP_LIB),x) | ||||
|     AST_LIBS+=$(CAP_LIB) | ||||
|   endif | ||||
| @@ -69,11 +67,7 @@ ifneq ($(findstring darwin,$(OSARCH)),) | ||||
|   ASTLINK+=/usr/lib/bundle1.o | ||||
| else | ||||
| # These are used for all but Darwin | ||||
|   ifneq ($(findstring LOADABLE_MODULES,$(MENUSELECT_CFLAGS)),) | ||||
|     ASTLINK+=-Wl,--export-dynamic | ||||
|   else | ||||
|     ASTLINK+=${GC_LDFLAGS} | ||||
|   endif | ||||
|   ASTLINK+=-Wl,--export-dynamic | ||||
|   ifneq ($(findstring BSD,$(OSARCH)),) | ||||
|     LDFLAGS+=-L/usr/local/lib | ||||
|   endif | ||||
| @@ -172,9 +166,6 @@ endif | ||||
|  | ||||
| stdtime/localtime.o: _ASTCFLAGS+=$(AST_NO_STRICT_OVERFLOW) -Wno-format-nonliteral | ||||
|  | ||||
| AST_EMBED_LDSCRIPTS:=$(sort $(EMBED_LDSCRIPTS)) | ||||
| AST_EMBED_LDFLAGS:=$(foreach dep,$(EMBED_LDFLAGS),$(value $(dep))) | ||||
| AST_EMBED_LIBS:=$(foreach dep,$(EMBED_LIBS),$(value $(dep))) | ||||
| OBJS:=$(sort $(OBJS)) | ||||
|  | ||||
| ifneq ($(findstring $(OSARCH), mingw32 cygwin ),) | ||||
| @@ -325,10 +316,10 @@ endif | ||||
|  | ||||
| tcptls.o: _ASTCFLAGS+=$(OPENSSL_INCLUDE) | ||||
|  | ||||
| $(MAIN_TGT): $(OBJS) $(ASTSSL_LIB) $(ASTPJ_LIB) $(LIBEDIT_OBJ) $(AST_EMBED_LDSCRIPTS) | ||||
| $(MAIN_TGT): $(OBJS) $(ASTSSL_LIB) $(ASTPJ_LIB) $(LIBEDIT_OBJ) | ||||
| 	@$(CC) -c -o buildinfo.o $(_ASTCFLAGS) buildinfo.c $(ASTCFLAGS) | ||||
| 	$(ECHO_PREFIX) echo "   [LD] $(OBJS) $(LIBEDIT_OBJ) $(AST_EMBED_LDSCRIPTS) -> $@" | ||||
| 	$(CMD_PREFIX) $(CXX) $(STATIC_BUILD) -o $@ $(ASTLINK) $(AST_EMBED_LDFLAGS) $(_ASTLDFLAGS) $(ASTLDFLAGS) $(OBJS) $(ASTSSL_LDLIBS) $(ASTPJ_LDLIBS) $(LIBEDIT_OBJ) $(AST_EMBED_LDSCRIPTS) buildinfo.o $(AST_LIBS) $(AST_EMBED_LIBS) $(GMIMELDFLAGS) $(LIBEDIT_LIB) | ||||
| 	$(ECHO_PREFIX) echo "   [LD] $(OBJS) $(LIBEDIT_OBJ) -> $@" | ||||
| 	$(CMD_PREFIX) $(CXX) $(STATIC_BUILD) -o $@ $(ASTLINK) $(_ASTLDFLAGS) $(ASTLDFLAGS) $(OBJS) $(ASTSSL_LDLIBS) $(ASTPJ_LDLIBS) $(LIBEDIT_OBJ) buildinfo.o $(AST_LIBS) $(GMIMELDFLAGS) $(LIBEDIT_LIB) | ||||
|  | ||||
| ifeq ($(GNU_LD),1) | ||||
| $(MAIN_TGT): asterisk.exports | ||||
|   | ||||
| @@ -109,10 +109,6 @@ static const unsigned char expected_key[] = | ||||
|  | ||||
| static char buildopt_sum[33] = AST_BUILDOPT_SUM; | ||||
|  | ||||
| static unsigned int embedding = 1; /* we always start out by registering embedded modules, | ||||
| 				      since they are here before we dlopen() any | ||||
| 				   */ | ||||
|  | ||||
| /*! | ||||
|  * \brief Internal flag to indicate all modules have been initially loaded. | ||||
|  */ | ||||
| @@ -146,14 +142,6 @@ const char *ast_module_name(const struct ast_module *mod) | ||||
| 	return mod->info->name; | ||||
| } | ||||
|  | ||||
| /* | ||||
|  * module_list is cleared by its constructor possibly after | ||||
|  * we start accumulating embedded modules, so we need to | ||||
|  * use another list (without the lock) to accumulate them. | ||||
|  * Then we update the main list when embedding is done. | ||||
|  */ | ||||
| static struct module_list embedded_module_list; | ||||
|  | ||||
| struct loadupdate { | ||||
| 	int (*updater)(void); | ||||
| 	AST_LIST_ENTRY(loadupdate) entry; | ||||
| @@ -182,15 +170,7 @@ static struct ast_module *resource_being_loaded; | ||||
|  | ||||
| void ast_module_register(const struct ast_module_info *info) | ||||
| { | ||||
| 	struct ast_module *mod; | ||||
|  | ||||
| 	if (embedding) { | ||||
| 		if (!(mod = ast_calloc(1, sizeof(*mod) + strlen(info->name) + 1))) | ||||
| 			return; | ||||
| 		strcpy(mod->resource, info->name); | ||||
| 	} else { | ||||
| 		mod = resource_being_loaded; | ||||
| 	} | ||||
| 	struct ast_module *mod = resource_being_loaded; | ||||
|  | ||||
| 	ast_debug(5, "Registering module %s\n", info->name); | ||||
|  | ||||
| @@ -206,18 +186,14 @@ void ast_module_register(const struct ast_module_info *info) | ||||
| 	   might be unsafe to use the list lock at that point... so | ||||
| 	   let's avoid it altogether | ||||
| 	*/ | ||||
| 	if (embedding) { | ||||
| 		AST_DLLIST_INSERT_TAIL(&embedded_module_list, mod, entry); | ||||
| 	} else { | ||||
| 		AST_DLLIST_LOCK(&module_list); | ||||
| 		/* it is paramount that the new entry be placed at the tail of | ||||
| 		   the list, otherwise the code that uses dlopen() to load | ||||
| 		   dynamic modules won't be able to find out if the module it | ||||
| 		   just opened was registered or failed to load | ||||
| 		*/ | ||||
| 		AST_DLLIST_INSERT_TAIL(&module_list, mod, entry); | ||||
| 		AST_DLLIST_UNLOCK(&module_list); | ||||
| 	} | ||||
| 	AST_DLLIST_LOCK(&module_list); | ||||
| 	/* it is paramount that the new entry be placed at the tail of | ||||
| 	   the list, otherwise the code that uses dlopen() to load | ||||
| 	   dynamic modules won't be able to find out if the module it | ||||
| 	   just opened was registered or failed to load | ||||
| 	*/ | ||||
| 	AST_DLLIST_INSERT_TAIL(&module_list, mod, entry); | ||||
| 	AST_DLLIST_UNLOCK(&module_list); | ||||
|  | ||||
| 	/* give the module a copy of its own handle, for later use in registrations and the like */ | ||||
| 	*((struct ast_module **) &(info->self)) = mod; | ||||
| @@ -431,8 +407,6 @@ static struct ast_module *find_resource(const char *resource, int do_lock) | ||||
| 	return cur; | ||||
| } | ||||
|  | ||||
| #ifdef LOADABLE_MODULES | ||||
|  | ||||
| /*! | ||||
|  * \brief dlclose(), with failure logging. | ||||
|  */ | ||||
| @@ -605,8 +579,6 @@ static struct ast_module *load_dynamic_module(const char *resource_in, unsigned | ||||
| 	return AST_DLLIST_LAST(&module_list); | ||||
| } | ||||
|  | ||||
| #endif | ||||
|  | ||||
| int modules_shutdown(void) | ||||
| { | ||||
| 	struct ast_module *mod; | ||||
| @@ -721,18 +693,11 @@ int ast_unload_resource(const char *resource_name, enum ast_module_unload_mode f | ||||
|  | ||||
| 	AST_DLLIST_UNLOCK(&module_list); | ||||
|  | ||||
| 	if (!error && !mod->lib && mod->info && mod->info->restore_globals) | ||||
| 		mod->info->restore_globals(); | ||||
|  | ||||
| #ifdef LOADABLE_MODULES | ||||
| 	if (!error) { | ||||
| 		unload_dynamic_module(mod); | ||||
| 		ast_test_suite_event_notify("MODULE_UNLOAD", "Message: %s", resource_name); | ||||
| 	} | ||||
| #endif | ||||
|  | ||||
| 	if (!error) | ||||
| 		ast_update_use_count(); | ||||
| 	} | ||||
|  | ||||
| 	return res; | ||||
| } | ||||
| @@ -1072,7 +1037,6 @@ static enum ast_module_load_result load_resource(const char *resource_name, unsi | ||||
| 		if (global_symbols_only && !ast_test_flag(mod->info, AST_MODFLAG_GLOBAL_SYMBOLS)) | ||||
| 			return AST_MODULE_LOAD_SKIP; | ||||
| 	} else { | ||||
| #ifdef LOADABLE_MODULES | ||||
| 		mod = load_dynamic_module(resource_name, global_symbols_only, suppress_logging, resource_heap); | ||||
| 		if (mod == MODULE_LOCAL_ONLY) { | ||||
| 				return AST_MODULE_LOAD_SKIP; | ||||
| @@ -1083,22 +1047,11 @@ static enum ast_module_load_result load_resource(const char *resource_name, unsi | ||||
| 			} | ||||
| 			return required ? AST_MODULE_LOAD_FAILURE : AST_MODULE_LOAD_DECLINE; | ||||
| 		} | ||||
| #else | ||||
| 		ast_log(LOG_WARNING, "Module support is not available. Module '%s' could not be loaded.\n", resource_name); | ||||
| 		return required ? AST_MODULE_LOAD_FAILURE : AST_MODULE_LOAD_DECLINE; | ||||
| #endif | ||||
| 	} | ||||
|  | ||||
| 	if (inspect_module(mod)) { | ||||
| 		ast_log(LOG_WARNING, "Module '%s' could not be loaded.\n", resource_name); | ||||
| #ifdef LOADABLE_MODULES | ||||
| 		unload_dynamic_module(mod); | ||||
| #endif | ||||
| 		return required ? AST_MODULE_LOAD_FAILURE : AST_MODULE_LOAD_DECLINE; | ||||
| 	} | ||||
|  | ||||
| 	if (!mod->lib && mod->info->backup_globals && mod->info->backup_globals()) { | ||||
| 		ast_log(LOG_WARNING, "Module '%s' was unable to backup its global data.\n", resource_name); | ||||
| 		return required ? AST_MODULE_LOAD_FAILURE : AST_MODULE_LOAD_DECLINE; | ||||
| 	} | ||||
|  | ||||
| @@ -1316,7 +1269,6 @@ done: | ||||
| int load_modules(unsigned int preload_only) | ||||
| { | ||||
| 	struct ast_config *cfg; | ||||
| 	struct ast_module *mod; | ||||
| 	struct load_order_entry *order; | ||||
| 	struct ast_variable *v; | ||||
| 	unsigned int load_count; | ||||
| @@ -1324,14 +1276,8 @@ int load_modules(unsigned int preload_only) | ||||
| 	int res = 0; | ||||
| 	struct ast_flags config_flags = { 0 }; | ||||
| 	int modulecount = 0; | ||||
|  | ||||
| #ifdef LOADABLE_MODULES | ||||
| 	struct dirent *dirent; | ||||
| 	DIR *dir; | ||||
| #endif | ||||
|  | ||||
| 	/* all embedded modules have registered themselves by now */ | ||||
| 	embedding = 0; | ||||
|  | ||||
| 	ast_verb(1, "Asterisk Dynamic Loader Starting:\n"); | ||||
|  | ||||
| @@ -1339,12 +1285,6 @@ int load_modules(unsigned int preload_only) | ||||
|  | ||||
| 	AST_DLLIST_LOCK(&module_list); | ||||
|  | ||||
| 	if (embedded_module_list.first) { | ||||
| 		module_list.first = embedded_module_list.first; | ||||
| 		module_list.last = embedded_module_list.last; | ||||
| 		embedded_module_list.first = NULL; | ||||
| 	} | ||||
|  | ||||
| 	cfg = ast_config_load2(AST_MODULE_CONFIG, "" /* core, can't reload */, config_flags); | ||||
| 	if (cfg == CONFIG_STATUS_FILEMISSING || cfg == CONFIG_STATUS_FILEINVALID) { | ||||
| 		ast_log(LOG_WARNING, "No '%s' found, no modules will be loaded.\n", AST_MODULE_CONFIG); | ||||
| @@ -1366,19 +1306,6 @@ int load_modules(unsigned int preload_only) | ||||
|  | ||||
| 	/* check if 'autoload' is on */ | ||||
| 	if (!preload_only && ast_true(ast_variable_retrieve(cfg, "modules", "autoload"))) { | ||||
| 		/* if so, first add all the embedded modules that are not already running to the load order */ | ||||
| 		AST_DLLIST_TRAVERSE(&module_list, mod, entry) { | ||||
| 			/* if it's not embedded, skip it */ | ||||
| 			if (mod->lib) | ||||
| 				continue; | ||||
|  | ||||
| 			if (mod->flags.running) | ||||
| 				continue; | ||||
|  | ||||
| 			add_to_load_order(mod->resource, &load_order, 0); | ||||
| 		} | ||||
|  | ||||
| #ifdef LOADABLE_MODULES | ||||
| 		/* if we are allowed to load dynamic modules, scan the directory for | ||||
| 		   for all available modules and add them as well */ | ||||
| 		if ((dir = opendir(ast_config_AST_MODULE_DIR))) { | ||||
| @@ -1407,7 +1334,6 @@ int load_modules(unsigned int preload_only) | ||||
| 				ast_log(LOG_WARNING, "Unable to open modules directory '%s'.\n", | ||||
| 					ast_config_AST_MODULE_DIR); | ||||
| 		} | ||||
| #endif | ||||
| 	} | ||||
|  | ||||
| 	/* now scan the config for any modules we are prohibited from loading and | ||||
|   | ||||
		Reference in New Issue
	
	Block a user