asterisk/build_tools
David M. Lee 9bed50db41 optional_api: Fix linking problems between modules that export global symbols
With the new work in Asterisk 12, there are some uses of the
optional_api that are prone to failure. The details are rather involved,
and captured on [the wiki][1].

This patch addresses the issue by removing almost all of the magic from
the optional API implementation. Instead of relying on weak symbol
resolution, a new optional_api.c module was added to Asterisk core.

For modules providing an optional API, the pointer to the implementation
function is registered with the core. For modules that use an optional
API, a pointer to a stub function, along with a optional_ref function
pointer are registered with the core. The optional_ref function pointers
is set to the implementation function when it's provided, or the stub
function when it's now.

Since the implementation no longer relies on magic, it is now supported
on all platforms. In the spirit of choice, an OPTIONAL_API flag was
added, so we can disable the optional_api if needed (maybe it's buggy on
some bizarre platform I haven't tested on)

The AST_OPTIONAL_API*() macros themselves remained unchanged, so
existing code could remain unchanged. But to help with debugging the
optional_api, the patch limits the #include of optional API's to just
the modules using the API. This also reduces resource waste maintaining
optional_ref pointers that aren't used.

Other changes made as a part of this patch:
 * The stubs for http_websocket that wrap system calls set errno to
   ENOSYS.

 * res_http_websocket now properly increments module use count.

 * In loader.c, the while() wrappers around dlclose() were removed. The
   while(!dlclose()) is actually an anti-pattern, which can lead to
   infinite loops if the module you're attempting to unload exports a
   symbol that was directly linked to.

 * The special handling of nonoptreq on systems without weak symbol
   support was removed, since we no longer rely on weak symbols for
   optional_api.

 [1]: https://wiki.asterisk.org/wiki/x/wACUAQ

(closes issue ASTERISK-22296)
Reported by: Matt Jordan
Review: https://reviewboard.asterisk.org/r/2797/
........

Merged revisions 397989 from http://svn.asterisk.org/svn/asterisk/branches/12


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@397990 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2013-08-30 13:40:27 +00:00
..
cflags-devmode.xml Refactor operations to access the stasis cache instead of objects directly when retrieving information. 2013-07-08 19:19:55 +00:00
cflags.xml optional_api: Fix linking problems between modules that export global symbols 2013-08-30 13:40:27 +00:00
embed_modules.xml Change the internal name of the menuselect options that are used to control 2011-10-14 21:37:51 +00:00
find_missing_support_level Multiple revisions 369001-369002 2012-06-15 16:20:16 +00:00
get_documentation remove empty awk pattern (//) 2009-10-28 20:50:52 +00:00
get_documentation.py Add AMI event documentation 2012-06-25 17:59:34 +00:00
get_makeopts Merged revisions 139909 via svnmerge from 2008-08-25 21:32:10 +00:00
get_moduleinfo Merged revisions 139909 via svnmerge from 2008-08-25 21:32:10 +00:00
make_build_h Merged revisions 260801 via svnmerge from 2010-05-04 15:49:57 +00:00
make_buildopts_h Clean up Makefile "warning" clutter when makeopts doesn't exist. 2013-04-08 18:24:50 +00:00
make_defaults_h Address OpenSSL initialization issues when using third-party libraries. 2012-01-30 21:21:16 +00:00
make_linker_eo_script give embedded modules a helping hand by backing up and restoring their global variables when they are loaded and unloaded 2007-02-22 02:36:00 +00:00
make_linker_version_script Clean up Makefile "warning" clutter when makeopts doesn't exist. 2013-04-08 18:24:50 +00:00
make_sample_voicemail Merged revisions 299907 via svnmerge from 2010-12-29 18:24:19 +00:00
make_version Clean up Makefile "warning" clutter when makeopts doesn't exist. 2013-04-08 18:24:50 +00:00
make_version_c Merged revisions 234699 via svnmerge from 2009-12-14 21:13:18 +00:00
menuselect-deps.in Add the bucket API. 2013-08-23 21:49:47 +00:00
mkpkgconfig Clean up Makefile "warning" clutter when makeopts doesn't exist. 2013-04-08 18:24:50 +00:00
post_process_documentation.py Migrate AMI VarSet events raised by GoSub local variables 2013-05-02 20:59:20 +00:00
prep_tarball Fix boo-boo in prep_tarball script. 2011-11-08 13:23:27 +00:00
sha1sum-sh Add an sha1sum-workalike for platforms which don't have it (like Mac OS X) 2010-05-18 22:49:13 +00:00