[Asterisk-code-review] loader: Use MODULEINFO tag to determine dlopen order (asterisk[master])

George Joseph asteriskteam at digium.com
Tue Jan 26 16:52:32 CST 2016


Hello Anonymous Coward #1000019,

I'd like you to reexamine a change.  Please visit

    https://gerrit.asterisk.org/2095

to look at the new patch set (#2).

Change subject: loader:  Use MODULEINFO tag to determine dlopen order
......................................................................

loader:  Use MODULEINFO tag to determine dlopen order

The current process doesn't work very well when one module marked
AST_MODFLAG_GLOBAL_SYMBOLS depends on another module also marked
AST_MODFLAG_GLOBAL_SYMBOLS.  In this case the order dlopen is called is the
order the OS returns them from an opendir call on the modules directory
which is non-deterministic. Although we use the RTLD_LAZY flag with dlopen,
that only defers resolution for function calls.  If moduleA references
a POINTER to a function in moduleB, then moduleB MUST be loaded before
moduleA.  This does happen with some pjproject calls.

Since we have the correct dependency tree in menuselect-tree at compile
time, this patch filters the menuselect-tree xml file through xsltproc
to produce a Makefile that represents the dependencies, then calls
'make all' on it to produce a header file containing an array of module
names in the proper load order.

loader.c includes that header and at runtime adds the contents to the
load_order list after modules.conf has been processed but before the
modules are read from the modules directory.  As the modules directory
is read, pre-existing logic ignores any that are already in the list
so only new modules like third-party modules are picked up.  Pre-existing
logic also removes any modules ones marked 'noload' in modules.conf.
The final list now only requires 1 pass instead of 1 for global symbols
and one for the rest. This in turn prevents the confusing messages we
sometimes see when a module fails to load the first time but silently
succeedes the second time.

NOTE:  This patch DOES NOT alter the AST_MODFLAG_LOAD_ORDER/load_pri
processing.  Modules still have their 'load' functions called in the
order specified by load_pri.

xsltproc is used to process menuselect-tree.  It was already included
in install_prereq for RH and BSD based systems.  Since I couldn't
verify it was incldued for Debian based systems, I added the xsltproc
package explicitly.

res_pjsip_pubsub and res_pjsip_session had incorrect load_pri settings
that placed them after modules that needed them to be initialized so
they were tweaked.

Change-Id: If7c84242a5fe2a433b7886505641c5d661111823
---
M Makefile
A build_tools/make_loaderdeps.xslt
M configure
M configure.ac
M contrib/scripts/install_prereq
M include/asterisk/.gitignore
M main/loader.c
M res/res_pjsip_pubsub.c
M res/res_pjsip_session.c
9 files changed, 109 insertions(+), 10 deletions(-)


  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/95/2095/2
-- 
To view, visit https://gerrit.asterisk.org/2095
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-MessageType: newpatchset
Gerrit-Change-Id: If7c84242a5fe2a433b7886505641c5d661111823
Gerrit-PatchSet: 2
Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Owner: George Joseph <george.joseph at fairview5.com>
Gerrit-Reviewer: Anonymous Coward #1000019



More information about the asterisk-code-review mailing list