Kevin,

Faidon Liambotis wrote:
> Unfortunately, Digium made a delibarate decision to break both the API
> and the ABI on the stable branch (1.4.15).
Attached is a proposed fix for ABI issue (buildopt_sum et al.).

Once this is applied, loading a pre-1.4.16 module (including those
compiled with 1.4.15!) will emit a warning such as this:

[Dec  5 02:22:12] WARNING[26391]: loader.c:625 inspect_module: Module
'format_mp3.so' was not compiled against a recent version of Asterisk
and may cause instability.

...and their buildopt sum will never be examined (and thus will never
get out of bounds on pre-1.4.15 versions).
However, all modules compiled with this version of module.h will have
their buildopt sum checked and behave as the current version does.

This keeps the ABI for the existing modules while introduces the so
wanted feature of the buildopt sum.

This is a 1.4 patch since it doesn't make any sense to apply this to
trunk which will have a different ABI anyway.

BTW, I'd suggest to add a "version" member to the struct in 1.6.
It would help in relevant situtations in the future.

Thanks,
Faidon
Index: include/asterisk/module.h
===================================================================
--- include/asterisk/module.h   (revision 91033)
+++ include/asterisk/module.h   (working copy)
@@ -179,6 +179,7 @@
 enum ast_module_flags {
        AST_MODFLAG_DEFAULT = 0,
        AST_MODFLAG_GLOBAL_SYMBOLS = (1 << 0),
+       AST_MODFLAG_BUILDSUM = (1 << 1),
 };
 
 struct ast_module_info {
@@ -233,7 +234,7 @@
                AST_MODULE,                             \
                desc,                                   \
                keystr,                                 \
-               flags_to_set,                           \
+               flags_to_set | AST_MODFLAG_BUILDSUM,    \
                AST_BUILDOPT_SUM,                       \
        };                                              \
        static void  __attribute__ ((constructor)) __reg_module(void) \
@@ -261,7 +262,7 @@
 #define AST_MODULE_INFO(keystr, flags_to_set, desc, fields...) \
        static struct ast_module_info __mod_info = {            \
                .name = AST_MODULE,                             \
-               .flags = flags_to_set,                          \
+               .flags = flags_to_set | AST_MODFLAG_BUILDSUM,   \
                .description = desc,                            \
                .key = keystr,                                  \
                .buildopt_sum = AST_BUILDOPT_SUM,               \
Index: main/loader.c
===================================================================
--- main/loader.c       (revision 91033)
+++ main/loader.c       (working copy)
@@ -615,8 +615,10 @@
                return 1;
        }
 
-       if (!ast_strlen_zero(mod->info->buildopt_sum) &&
-           strcmp(buildopt_sum, mod->info->buildopt_sum)) {
+       if (!ast_test_flag(mod->info, AST_MODFLAG_BUILDSUM)) {
+               ast_log(LOG_WARNING, "Module '%s' was not compiled against a 
recent version of Asterisk and may cause instability.\n", mod->resource);
+       } else 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;
_______________________________________________
--Bandwidth and Colocation Provided by http://www.api-digital.com--

asterisk-dev mailing list
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-dev

Reply via email to