[asterisk-commits] kpfleming: branch 1.4 r89461 - in /branches/1.4: build_tools/ include/asteris...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Nov 20 13:12:53 CST 2007


Author: kpfleming
Date: Tue Nov 20 13:12:52 2007
New Revision: 89461

URL: http://svn.digium.com/view/asterisk?view=rev&rev=89461
Log:
bring back compile-option checking when loading modules, only this time use a string-based storage and comparison mechanism because it is easier to support on other platforms

Modified:
    branches/1.4/build_tools/make_buildopts_h
    branches/1.4/include/asterisk/module.h
    branches/1.4/main/loader.c

Modified: branches/1.4/build_tools/make_buildopts_h
URL: http://svn.digium.com/view/asterisk/branches/1.4/build_tools/make_buildopts_h?view=diff&rev=89461&r1=89460&r2=89461
==============================================================================
--- branches/1.4/build_tools/make_buildopts_h (original)
+++ branches/1.4/build_tools/make_buildopts_h Tue Nov 20 13:12:52 2007
@@ -14,4 +14,16 @@
 if ${GREP} AST_DEVMODE makeopts | ${GREP} -q yes
 then
 	echo "#define AST_DEVMODE 1"
+	TMP="${TMP} AST_DEVMODE"
 fi
+
+case ${OSARCH} in	# actually we should check build_os
+*BSD|mingw|darwin*)
+	BUILDSUM=`echo ${TMP} | md5 | cut -c1-32`
+	;;
+*)
+	BUILDSUM=`echo ${TMP} | md5sum | cut -c1-32`
+	;;
+esac
+
+echo "#define AST_BUILDOPT_SUM \"${BUILDSUM}\""

Modified: branches/1.4/include/asterisk/module.h
URL: http://svn.digium.com/view/asterisk/branches/1.4/include/asterisk/module.h?view=diff&rev=89461&r1=89460&r2=89461
==============================================================================
--- branches/1.4/include/asterisk/module.h (original)
+++ branches/1.4/include/asterisk/module.h Tue Nov 20 13:12:52 2007
@@ -203,6 +203,7 @@
 
 	const char *key;
 	unsigned int flags;
+	const char buildopt_sum[33];		/* The value of AST_BUILDOPT_SUM when this module was compiled */
 };
 
 void ast_module_register(const struct ast_module_info *);
@@ -229,7 +230,8 @@
 		AST_MODULE,				\
 		desc,					\
 		keystr,					\
-		flags_to_set				\
+		flags_to_set,				\
+		AST_BUILDOPT_SUM,			\
 	};						\
 	static void  __attribute__ ((constructor)) __reg_module(void) \
 	{ \
@@ -259,6 +261,7 @@
 		.flags = flags_to_set,				\
 		.description = desc,				\
 		.key = keystr,					\
+		.buildopt_sum = AST_BUILDOPT_SUM,		\
 		fields						\
 	};							\
 	static void  __attribute__ ((constructor)) __reg_module(void) \

Modified: branches/1.4/main/loader.c
URL: http://svn.digium.com/view/asterisk/branches/1.4/main/loader.c?view=diff&rev=89461&r1=89460&r2=89461
==============================================================================
--- branches/1.4/main/loader.c (original)
+++ branches/1.4/main/loader.c Tue Nov 20 13:12:52 2007
@@ -76,6 +76,8 @@
 { 0x87, 0x76, 0x79, 0x35, 0x23, 0xea, 0x3a, 0xd3,
   0x25, 0x2a, 0xbb, 0x35, 0x87, 0xe4, 0x22, 0x24 };
 
+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
 				   */
@@ -613,6 +615,13 @@
 		return 1;
 	}
 
+	if (!ast_strlen_zero(mod->info->buildopt_sum) &&
+	    strcmp(buildopt_sum, mod->info->buildopt_sum)) {
+		ast_log(LOG_WARNING, "Module '%s' was not compiled with the same compile-time options as this version of Asterisk.\n", mod->resource);
+		ast_log(LOG_WARNING, "Module '%s' will not be initialized as it may cause instability.\n", mod->resource);
+		return 1;
+	}
+
 	return 0;
 }
 




More information about the asterisk-commits mailing list